You are here: irt.org | FAQ | JavaScript | Form | Q1449 [ previous next ]
Use the onChange (or possibly onBlur) event handler:
<script language="JavaScript"><!-- function fieldvalidate(theField) { if (theField.value != 'blabla') { alert('Please enter blablabla in ' + theField.name); theField.focus() } } //--></script> <form> <input type="text" onChange="fieldvalidate(this)"> </form>