0
votes

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.

2
Give both submit buttons the SAME name. Then your JS can just see if (submit.name == 'login') { do login validation } else { do register validation }Marc B
can you explain it more. didn't get uMann

2 Answers

1
votes

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!

0
votes

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.