简体   繁体   中英

Two submit buttons with different actions?

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.

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!

如果希望仅在单击注册时才运行验证,则不应将验证功能链接到表单提交事件,而是链接到注册按钮onclick事件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM