No validation don't show next fieldset

Multi tool use
Multi tool use


No validation don't show next fieldset



I'm creating a multi-step form using this example - codepen.io/orozcokapo/pen/LmgjYg


codepen.io/orozcokapo/pen/LmgjYg



But, I want that in second fieldset, first validate required input textfield (I am using only one Textfield on second fieldset for mobile number input) and the button to go to the next step should work if the required field is not empty.



I am unable to code it in JQuery. Could you please guide me how to do that?




1 Answer
1



First, designate which inputs are required by giving them the required attribute. Then, at the Next button's click function, move current_fs = $(this).parent(); to the top and add this code


required


current_fs = $(this).parent();


var inputs = current_fs.find("input[required]");
if(inputs.is((i,el) => $(el).val() == ""))
{
alert("Please fill out all required fields");
return false;
}



https://codepen.io/anon/pen/zaeNMP





Thanks for help. This code is not working. Throwing error Uncaught SyntaxError: Illegal return statement
– Akola
Jul 1 at 5:18



Uncaught SyntaxError: Illegal return statement





Did you add the block of code immediately after the current_fs line?
– DoomTay
Jul 1 at 5:33


current_fs





Sorry my mistake. Thanks working now. But, when onclick submit if required field is empty it is displaying alert and if I enter value to input field on same page without refreshing then submit button is not clicakble. How to solve this now?
– Akola
Jul 1 at 5:42






That sounds like it merits a separate question
– DoomTay
Jul 1 at 5:46





Okay Thanks for help. I will try to solve this problem. If not, then will post a question.
– Akola
Jul 1 at 6:39






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

JaRPh54QTU6a4AeIKeY9 JLbLIIPJdiE
so,lgQw2JyX vRuXMqEmt3Sm1kw krDg9jVMaMHPaS 4jjqR,q5AW1bHhP,nM Nk,YS1Edm09KbW

Popular posts from this blog

PySpark - SparkContext: Error initializing SparkContext File does not exist

django NoReverseMatch Exception

List of Kim Possible characters