You are here: irt.org | FAQ | JavaScript | Form | 5 | Q816 [ previous next ]
Try:
<SCRIPT LANGUAGE="JavaScript"><!-- function validate(string,length) { if (string.length > length) { alert('too long'); return false; } if (string.length < length) { alert('too short'); return false; } var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" for (var i=0; i<length; i++) { if (valid.indexOf(string.charAt(i)) < 0) { alert('invalid characters'); return false; } } return true; } //--></SCRIPT>