I need to know how to make a form auto submit after I tab out of it or lose any focus on it if it says what I want it to say (the word PASS). My initial thought is to use onblur=“submitform();” but how do I make it only do that if it ALSO says the word PASS?
Here is a form with a field in it.
<form id="autopass">
<p><input name="codeword"></p>
</form>
Attach an onblur event to the field:
var form = document.getElementById('autopass'),
field = form.elements.codeword;
field.onblur = fieldBlurHandler;
The fieldBlurHandler function is where you can check that its value matches. If it matches, then you can submit the form.
function fieldBlurHandler() {
if (this.value === 'PASS') {
this.form.submit();
}
}