Reputation: 10586
I have this form in my web page
<form method="POST" action="http://www.example.com/gotothisURL">
........
Two buttons here , one for submit and one for validation
</form>
Now when I click "Submit" , the page is redirected to the URL, but it also does the same thing when I click "Validation". I don't want page to be redirected on click of "validation", but I do want to do some cross site validation on server side.
Upvotes: 2
Views: 2415
Reputation: 141
The validation should work in two steps. Firstly the form must validate on the client side, using JavaScript. Then once the client side script has determined the form is valid it can be sent to the server for further validation.
Unless there is a specific reason for the validation button I would avoid using this. Just allow the form to be validated by JavaScript when the user clicks submits, if it passes the initial validation then it can be sent to the server, otherwise, you can display relevant messages on the screen explaining to the user what they must do in order for the form to be valid.
Upvotes: 1