Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form | Q1449 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.