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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't this form validation work on a Mac? 2

Status
Not open for further replies.
Apr 6, 2001
41
0
0
US
This form validation works fine on a PC but not on a Mac. Anyone know why? What can I do to fix this problem???

My friend tells me that the form action submits anyway after he clicks OK on any of my validation alerts. He tried it in both IE and NS (on a Mac).


---This is in the HEAD of the document----------

<script language=&quot;JavaScript&quot;>
<!--

function validate() {
mNv=mainform.LastName.value;
if (mNv=='') {
alert('LAST NAME is a required field. Please try again.');
event.returnValue=false;
}
}
//-->
</script>


---This is in the BODY of the document----------

<form name=&quot;mainform&quot; action=&quot;BlahBlah.cfm&quot; onSubmit=&quot;validate()&quot; method=&quot;POST&quot;>
<input type=&quot;TEXT&quot; name=&quot;LastName&quot;>
</form>


Thanks for your help!
 
Hi,

It's because event.returnValue is not understand under MAC, just use &quot;return&quot; method like:

function validate() {
mNv=mainform.LastName.value;
if (mNv==&quot;&quot;) {
alert('LAST NAME is a required field. Please try again.');
return false;
};

I get the same problem and that's how I fix it.

Hope this helps...
 
SeAL: Thank you, but your solution doesn't work correctly on a PC. On a PC it just gives the alert then submits anyway. Any other ideas?

FYI: I have seven fields to validate. I just posted the code for the first one as a code example.
 
I fixed the problem. Thanks for your help! I voted for both of you because you both helped me along the way.
 
Wait, I'm having the same problem! What was the fix?

Thanks,
Inger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top