Custom form - show/hide sections


(Joy) #1

Hi all,

 

Squiz newbie here! I'm trying to create a custom form that has a checkbox list that will show/hide sections of the form when selected. I believe I will need to use javascript to do this. Can someone point me to the code for this or an example form that I can look at?

 

I will need to:

  • On the hidden sections of the form, have validation on the fields that will only be valid if it has been 'shown'
  • When submitting the form and there are validation errors, have the 'shown' sections still visible/open so that the errors can be seen
  • When resetting the form, have the form fully reset itself and not just clear the fields i.e. the checkbox list should be unchecked

Any help is much appreciated.

 

Thanks


(Nick Papadatos) #2

Yes, you'll need javascript

Have you created the form fields needed yet? if so can you copy the code behind (in the browser) and send it to me via email?


(Joy) #3

Some javascript that is helpful to do the show/hide:

 

http://codepen.io/renvrant/pen/ogeeBY

https://github.com/jrsinclair/jquery-dependent-questions