+ 1
Using two submit buttons
I have two submit button. One is particularly submit button and another one is particularly a verifyotp button. I want to send a mobile number field using verifyotp button to a script which will verify otp. And then I want to use submit button to send all data to database. I'm having problem in seprating them to make there way to the desired place. Any suggestions.
16 Answers
+ 1
You can design the ui to make it look like it is a part of the form. The same way some people make a "or log in" link look like it is part of a sign up form
+ 2
Use AJAX for the mobile number field
+ 1
Yup I can do that
0
In the submit event, call event.preventDefault();
https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
0
I already used it... It's not working the way I want
0
The problem is likely to be from your ajax method. Can you post the code. Like just remove any sensitive detail and post the code
0
Also a form should have only one submit button. The other button should not have a type of submit
0
Yup I know another button cannot be submit... But if I'll use the type="button" then what's the point I would not be able to redirect my code to a php file which is going to send otp
0
Ore Adeleye Do you have any other option ?
0
You can use the type submit on the submit button and use ajax to verify otp on the other button
0
Ore Adeleye I got that thing working. The problem I will face I think would be -
Suppose users doesn't fill the fname , mname and thinks that he will verify his otp first. Then the problem would come because all the above fields are set to 'required'.
Should I remove 'required' from html 5 and will validate them inside a loop in Jquery... Or do you have any other option?
0
It is a normal thing to verify with otp only after the user as filled in the details. But if you don't like that behaviour why don't you put the button outside the form because right now it seems like it is not a part of the form
0
Yup I can do that also but that would not look like user friendly
0
I'm planning to run a script which will verify the submitted otp and then will execute a condition ...in which submit button get's enabled and to submit the form then you will require all the field..
Thanks For the help Ore Adeleye
0
Thnks bro
0
Instead of button you can call ajax on onchage event on mobile number field