SiteExperts.com Logo Home | Community | Developer's Paradise | Jobs
User Groups | Site Tools | Site Information | Search

Inside Technique : Form Validation Made Easy : Cross-Browser Form Validation

In order to make the validation cross-browser compatible, we are forced to abandon the expando attributes which Netscape does not recognize. In Netscape, the only way to set or retrieve non-standard properties on HTML elements is to use script; Netscape has neither support for, nor counterpart to, the getAttribute, setAttribute and removeAttribute methods available in Internet Explorer.

I have written a second validation script for use in any JavaScript 1.2 compliant browser. Place this script into your page the same way as you did the previous script, just before the ending BODY tag. The script runs in-line so it is important that the script be included after all FORM elements have been defined.

<script language="JavaScript1.2" src="nn-validation.js" type="text/javascript"></script>

Since the script can not read attributes directly from the page's HTML, you as a developer are responsible for turning on the validation checks using a short JavaScript block.