Forum Moderators: open

Message Too Old, No Replies

java script for required form fields works in IE but nothing else

         

mgworek

1:34 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



I testing my page with firefox and with browsers on my mac and they dont work. The message pops up letting them know they need to enter in data like it is supposed to but when you hit ok, it moves on to the next step instead of staying on the form for them to enter in data.

Here is part of my script. It is the first rule.

<SCRIPT>
function validate() {
pav=partner.pharmacy.value;
if (pav=='') {
alert('You must enter a valid Pharmacy Name. Please try again.');
event.returnValue=false;
}
}
</SCRIPT>

Here is the start of my form.
<form name= "partner" action="lead_done.php" method="post"
onsubmit="validate();">

Thank you.

kaled

3:30 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've assumed that there is a an input field named pharmacy. Try this...

<form name= "partner" action="lead_done.php" method="post"
onsubmit="return validate(this);">

function validate(form) {
if (form.pharmacy.value=='') {
alert('You must enter a valid Pharmacy Name.');
form.pharmacy.focus();
return false;
}
return true;
}

Kaled.

mgworek

4:31 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



I will give that a try.

and yes, there is a field in the form called that, sorry for not posting it.

<td colspan="3">Pharmacy Name: </td>
<td><input type="text" name="pharmacy"></td>