Checking form validity without Observables (with bug)
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.1.0/rx.all.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.3/foundation.css">
<form>
<input type="text" placeholder="field1" id="field1"></input>
<input type="text" placeholder="field2" id="field2"></input>
</form>
<p>
The form is currently: <strong id="validity">Invalid</strong>
</p>
Babel + JSX
function checkValidity(){
return document.getElementById('field1').value.length > 0 && document.getElementById('field2').value.length > 0;
}
function setValidity(isValid){
document.getElementById('validity').innerHTML = isValid ? 'Valid' : 'Invalid';
}
document.getElementById('field2').addEventListener('input', () => setValidity(checkValidity()));