R
roman
Hi,
I have a form which validates data before submitting, it catches the
error, but still submits and can't seem to figure out why. Can someone
look at my code and give me some ideas how to make it work? I need to
be able to submit by clicking on button and also by pressing on the
Enter key.
Here are my results
Internet Explorer 5. :
Enter Key: works fine
Send: catches error but sumbits
Firefox 1.07 :
Enter Key: catches error but sumbits
Click Send: catches error but sumbits
Thanks,
Roman
Code is here:
<html><head><title>Starting Point</title></head>
<script>
<!-- Hide script
function verifyData(TicketForm, FromOnClick) {
alert ("in verifyData");
if (FromOnClick) {
alert ("FromOnClick");
return true;
}
if (TicketForm.YourName.value == "" ) {
alert ("Please enter your Name!");
return false;
}
return true;
}
// End script hiding -->
</script>
<body>
<form action="Ending.html" method="post" enctype="multipart/form-data"
name="StartingPoint" onsubmit="return verifyData(this,false)">
<b>Your Name Is: </b>
<input name=Your Name id="YourName" size="15" value="">
<b> <input onclick="if( verifyData(document.forms.StartingPoint,true)
){document.StartingPoint.submit();}" value="Send"
type="submit"></b></font>
</form>
</body>
</html>
==== The Ending.html code is here:
<html><head><title>Ending Point</title></head>
<body>
<b> Thanks ! <b>
</body></html>
I have a form which validates data before submitting, it catches the
error, but still submits and can't seem to figure out why. Can someone
look at my code and give me some ideas how to make it work? I need to
be able to submit by clicking on button and also by pressing on the
Enter key.
Here are my results
Internet Explorer 5. :
Enter Key: works fine
Send: catches error but sumbits
Firefox 1.07 :
Enter Key: catches error but sumbits
Click Send: catches error but sumbits
Thanks,
Roman
Code is here:
<html><head><title>Starting Point</title></head>
<script>
<!-- Hide script
function verifyData(TicketForm, FromOnClick) {
alert ("in verifyData");
if (FromOnClick) {
alert ("FromOnClick");
return true;
}
if (TicketForm.YourName.value == "" ) {
alert ("Please enter your Name!");
return false;
}
return true;
}
// End script hiding -->
</script>
<body>
<form action="Ending.html" method="post" enctype="multipart/form-data"
name="StartingPoint" onsubmit="return verifyData(this,false)">
<b>Your Name Is: </b>
<input name=Your Name id="YourName" size="15" value="">
<b> <input onclick="if( verifyData(document.forms.StartingPoint,true)
){document.StartingPoint.submit();}" value="Send"
type="submit"></b></font>
</form>
</body>
</html>
==== The Ending.html code is here:
<html><head><title>Ending Point</title></head>
<body>
<b> Thanks ! <b>
</body></html>