Why would it be that when I call a function:
"
function validateZip(textObj)
{ // Must be all numbers and 5 digits
var str = textObj.value
var aChar = ""
var formObj = document.frmAbstractor
if (str.length != 5) {
alert('Please enter a valid Zip Code.');
document.frmAbstractor.txtZip.focus();
document.frmAbstractor.txtZip.select();
return;
}
for (var i=0; i < str.length; i++) {
aChar = str.charAt(i);
if (isNaN(aChar)) {
alert('Zip Code must be numbers only.');
document.frmAbstractor.txtZip.select();
return;
}
}
return;
}
"
... with the following code:
"<input type="text" name="txtZip" id="txtZip" value="<%=varZip%>" maxlength="5" size="5" onChange="validateZip(this)" class="RequiredField">"
When it's supposed to throw the alert and set focus back to the txtZip field, it's still setting focus on the next field in the form??? As you can see I've tried just Focus() and Select() and both... nothing...
"
function validateZip(textObj)
{ // Must be all numbers and 5 digits
var str = textObj.value
var aChar = ""
var formObj = document.frmAbstractor
if (str.length != 5) {
alert('Please enter a valid Zip Code.');
document.frmAbstractor.txtZip.focus();
document.frmAbstractor.txtZip.select();
return;
}
for (var i=0; i < str.length; i++) {
aChar = str.charAt(i);
if (isNaN(aChar)) {
alert('Zip Code must be numbers only.');
document.frmAbstractor.txtZip.select();
return;
}
}
return;
}
"
... with the following code:
"<input type="text" name="txtZip" id="txtZip" value="<%=varZip%>" maxlength="5" size="5" onChange="validateZip(this)" class="RequiredField">"
When it's supposed to throw the alert and set focus back to the txtZip field, it's still setting focus on the next field in the form??? As you can see I've tried just Focus() and Select() and both... nothing...