I am sure this is a simple issue, but being a beginner I am struggling.
In the following js function I am attempting to make sure no numbers are
within "name" controls. I want to pass the text value of the HTML
control and the control name into the function:
function CheckForNumbers (strString, strField) {
var result = true;
var validNums = "0123456789 ";
var alertHeader = "The following error(s) occured:\n\n";
var alertErr = "";
for (x=0; x < strString.lengt h; x++) {
if (validNums.inde xOf(strString.c harAt(x)) != -1) {
alertErr += "->This Field Cannot Contain Numbers\n";
break;
}
}
if (alertErr) {
result = false;
document.getEle mentById(strFie ld).focus();
alert (alertHeader + alertErr);
}
return result;
}
I don't know if this is the smartest way to do this, just the way I
thought of. The bottom line is I would like the code to check the value
to see if there is a number, and set focus back to the offending control
for the user to correct the problem. This works without a problem in
Internet Explorer, version 6 (latest Service packs, hot fixes, etc), but
in Netscape, version 7.2, I am getting the following error in the
JavaScript console:
Error: document.getEle mentById(strFie ld) has no properties
Source File: http://127.0.0.1:8100/TestJscript.jsp
Line: 104
Sorry this is so long, but I wanted to be as complete as possible and I
appreciate any help.
Ron
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Comment