You are here: irt.org | FAQ | JavaScript | Number | Q618 [ previous next ]
Try:
<SCRIPT language="JavaScript"><!-- function isValid(string,allowed) { for (var i=0; i< string.length; i++) { if (allowed.indexOf(string.charAt(i)) == -1) { alert('Invalid'); return false; } } return true; } var valid = '0123456789ABCDEFabcdef'; // define valid characters //--></SCRIPT> <FORM NAME="myForm" onSubmit="return isValid(document.myForm.input.value,valid)"> <INPUT TYPE="TEXT" NAME="input"> <INPUT TYPE="SUBMIT" VALUE="Valid?"> </FORM>