Form Toggler is a jQuery plug-in which allows elements to be hidden or shown based on the value of a form component.
- Add
jquery.formToggler.js
to your project, along with jQuery. - Create your form. When you reach an element that you would like to be conditionally hidden, give it
data-ft-name
anddata-ft-value
attributes, where the first is the name of the element to check, and the second is the value that will cause the conditional element to be visible. - Add the following jQuery to your page, to be executed on load:
$('#form').formToggler();
...where #form
is a selector for the <form>
element.
A demo is available in demo.html.
- Written by Chris Cook