You are viewing limited content. For full access, please sign in.

Question

Question

skip required validation in sections and fields has style disply none

asked on October 31, 2018

I have a form that had some sections, i make tabs to open specific section when click on tab and hide another sections, user can fill data in only one section and not necessary to fill all sections.

the problem i face when user try to submit the form the form validate the required fields under others tabs

so i need to validate required attr only under current tab and skip others.

Thank you.

1 0

Answer

SELECTED ANSWER
replied on October 31, 2018 Show version history

@████████,

Here is some code that turns off all required feilds in the entire form:

          	$('#form1 :input').attr('required', false);

Swap out the selector "#form1" with whatever your elements are.  

What Chris Douglas said is completely true too and less work. You should get familiar with Field Rules when you have a chance. Field Rules automatically make all required fields "un-required" when a section or field is hidden.

Good Luck!

Chris

2 0

Replies

replied on October 31, 2018

Hi Mahmoud,

 

If you want to hide required fields, then you'll need to use field rules to implement this, not sections. Good luck!

0 0
replied on October 31, 2018

I already create the form and use jquery codes to handle hide and show sections and fields when click tab, so i ask if there is any solution i can do with javascript or jquery.

thank you.

0 0
replied on October 31, 2018

I'm not sure you can do this with jquery, as a test I would try setting it up under field rules and firstly see if it resolves the issue.

2 0
replied on October 31, 2018

Ok, Thank you

0 0
SELECTED ANSWER
replied on October 31, 2018 Show version history

@████████,

Here is some code that turns off all required feilds in the entire form:

          	$('#form1 :input').attr('required', false);

Swap out the selector "#form1" with whatever your elements are.  

What Chris Douglas said is completely true too and less work. You should get familiar with Field Rules when you have a chance. Field Rules automatically make all required fields "un-required" when a section or field is hidden.

Good Luck!

Chris

2 0
replied on October 31, 2018

I gave all of fields i face problem in it's attribute one class and use jquery code to add or remove required attr. to them.

For sure next time i will use field rule.

Thank you for your help.

1 0
replied on October 31, 2018

You are welcome! 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.