Reputation: 5507
I have a form having login button and registeration button.
Registeration Button:
This button should deal two text boxes name and email:
<div id="regisbutton" class="regisbutton1">
<input type="submit" value="Register" class="regisbutton" name="registerSubmit"/>
</div>
Login Button:
This button should also consider only two textboxes username and password:
<div id="loginbutton" class="loginbuttonclass">
<input type="submit" value="Login" class="loginbutton" name="loginSubmit" />
</div>
Problem is I put validation JavaScript which runs automatically and before form action it checks if text boxes are empty or not. But I want to run this JavaScript for registeration textboxes only not for login textboxes.
I have used submit type for both buttons.
Upvotes: 0
Views: 600
Reputation: 3689
You are using two different actions, so you need to different forms!
Without the <form>
tag, the input button is quite useless anyway! Also don't rely on javascript only, validate the form with php as well in case js is turned off by the client!
So just wrap each submit button in a different form with a different action/validation and you're done!
Upvotes: 1
Reputation: 122
If you want validation to only run if you click register, you shouldnt link the validation function to the form submit event but to the register button onclick event.
Upvotes: 0