Hi. Can someone take a look at this? I'm trying to validate this form field during the html form submission. I want it to make sure the field contains alpha numeric characters with a length of 9. Right now it is only letting a user submit 9 numbers. Any help is greatly appreciated.
if (theForm.ID.value.length != 9)
{
alert("Please enter only 9 characters, with no dashes or spaces, in the \"ID\" field."
;
theForm.ID.focus();
return (false);
}
var checkOK = "0123456789";
var checkStr = theForm.ID.value;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
allNum += ch;
}
if (!allValid)
{
alert("Please enter only 9 characters, with no dashes or spaces, in the \"ID\" field."
;
theForm.ID.focus();
return (false);
}
return (true);
}
if (theForm.ID.value.length != 9)
{
alert("Please enter only 9 characters, with no dashes or spaces, in the \"ID\" field."
theForm.ID.focus();
return (false);
}
var checkOK = "0123456789";
var checkStr = theForm.ID.value;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
allNum += ch;
}
if (!allValid)
{
alert("Please enter only 9 characters, with no dashes or spaces, in the \"ID\" field."
theForm.ID.focus();
return (false);
}
return (true);
}