![]() | |
#1
| |||
| |||
|
#2
| ||||||
| ||||||
|
|
I have the following: input type="image" src="images/submit.jpg" width="70" height="30" border="0" onclick="validateRegister()" / |
|
It is inside a form where: form action="register_submit.php" name="register" id="register" method="post" |
|
At the end of validateRegister() I have: if (msg.length > 0) { alert(msg); |
|
} else { document.register.submit(); |
|
} after having built the msg based upon any errors. (It starts with var msg = '' ![]() What I am happening is that it alerts the message of all the errors because msg.length > 0, but then it submits the page!!! Even if I comment out the document.register.submit(), it still submits it. |
|
How can it submit the page if not a single call is made to post and there is not button for submit? |
#3
| |||
| |||
|
|
sheldonlg <sheldonlg> wrote in news:ypmdnfVjedBd9K7VnZ2dnUVZ_gednZ2d (AT) giganews (DOT) com: I have the following: input type="image" src="images/submit.jpg" width="70" height="30" border="0" onclick="validateRegister()" / Remove the onclick on the image submit. It is inside a form where: form action="register_submit.php" name="register" id="register" method="post" Add onsubmit="return validateRegister();" to the form. At the end of validateRegister() I have: if (msg.length > 0) { alert(msg); add return false; } else { document.register.submit(); replace document.register.submit(); with return true; } after having built the msg based upon any errors. (It starts with var msg = '' ![]() What I am happening is that it alerts the message of all the errors because msg.length > 0, but then it submits the page!!! Even if I comment out the document.register.submit(), it still submits it. Input type="image" is your submit button. |
|
How can it submit the page if not a single call is made to post and there is not button for submit? Your submit button is the input image. |
|
Javascript validation is only a courtesy to the user, do validate on the server. |
#4
| |||
| |||
|
|
sheldonlg <sheldonlg> wrote in news:ypmdnfVjedBd9K7VnZ2dnUVZ_gednZ2d (AT) giganews (DOT) com: I have the following: input type="image" src="images/submit.jpg" width="70" height="30" border="0" onclick="validateRegister()" / Remove the onclick on the image submit. It is inside a form where: form action="register_submit.php" name="register" id="register" method="post" Add onsubmit="return validateRegister();" to the form. At the end of validateRegister() I have: if (msg.length > 0) { alert(msg); add return false; } else { document.register.submit(); replace document.register.submit(); with return true; |
![]() |
| Thread Tools | |
| Display Modes | |
| |