Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1449 Is it possible to validate a form field as the use move tos the next one?

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>

©2018 Martin Webb