16 AnswersNew Answer
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.
5/2/2020 11:10:40 AMVishal Srivastava
16 AnswersNew Answer
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
Use AJAX for the mobile number field
Yup I can do that
In the submit event, call event.preventDefault(); https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
I already used it... It's not working the way I want
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
Also a form should have only one submit button. The other button should not have a type of submit
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
Ore Adeleye Do you have any other option ?
You can use the type submit on the submit button and use ajax to verify otp on the other button
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?
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
Yup I can do that also but that would not look like user friendly
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
Instead of button you can call ajax on onchage event on mobile number field
Sololearn Inc.535 Mission Street, Suite 1591
Send us a message