Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very simple form validation suddenly failing. Is it IE SP2?

Status
Not open for further replies.

kempis555

Programmer
Jan 2, 2001
77
0
0
After about 2 years of faithful service, a quick form I made has stopped working for 3 users (as far as I know). The one user I could get a hold of said she was using IE 6.2 with service pack 2. When she filled out the form, the javascript said she did not have anything in one required field, even though she wrote something in there.

Has there been any troubles with the new service pack?

For me it works fine in IE 6.0.2, Firefox 0.8, Netscape7, and Opera.

The script looks something like this:

<script language="javascript">
<!--
function check(){
var validity = 1;
var message = "";
if (document.form.inquirer_name.value == ""){
message = message + "Please enter an inquirers name.\n\n";
validity = 0;
}
if (document.form.owner_name.value == ""){
message = message + "Please enter an owners name.\n\n";
validity = 0;
}


... (13 other field validations like the above) ...



if (document.form.other_lines.value == ""){
message = message + "Please enter other lines carried.\n\n" ;
validity = 0;
}
else{
if ( (document.form.email.value.indexOf('\@') == -1) || (document.form.email.value.indexOf('.') == -1) ){
message = message + "Invalid email address... \n\n" ;
validity = 0;
}
}
if (validity == 1){
return true;
}
else{
alert(message);
return false;
}
}
//-->
</script>


 
AFAIK, XP/SP2 doesn't introduce any problems with form access.

My first suggestion would be to not name your form "form", as it is a reserved word.

My second suggestion would be to change your form field access code from this syntax:

Code:
document.formName.fieldName.value

to this:

Code:
document.forms['formName'].elements['fieldName'].value

Hope this helps,
Dan
 
That second code fragment is an interesting idea. I'll try those two out and see what happens.

Thanks,

-k
 
can u also give us a link???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top