View on GitHub

Parsely-conditions

A jQuery plugin that adds conditional logic to the Parsely.js form validation library

Download this project as a .zip file Download this project as a tar.gz file

< Back to home

Example of Nested Conditions

This example shows how you can nest conditions. Selecting "No" shows more fields and adds additional validation. Checking off "No" also toggles multiple DOM elements on and off. Lastly, checking off "business" adds another field and more validation.

Is your shipping address the same?
Yes:
No:
You indicated a different shipping address please enter the details below.
Your address:

Type of address:
Business
Deliver only during business hours?

Here's the plugin code used for this example.

var fValidate = $.parselyConditions({
        formname: 'customForm',
        validationfields: [
            {
                fid: 'formTrigger',
                ftype: 'radio',
                fvalue: 'different',
                faffected: ['address','type'],
                fhide: ['maskDiv','maskDiv3']
            },
            {
                fid: 'type',
                ftype: 'checkbox',
                fvalue: 'business',
                faffected: 'hours',
                fhide: 'maskDiv2'  
            }
        ],
    });