Display Form Fields Based on Selection using jQuery – conditionize

Yet another Text & Input plugin for jQuery to create display form fields based on selection. The plugin, “conditionize” is a lightweight and highly configurable plugin for jQuery. With the help of this plugin, you can show / hide form fields depending on entered values, select dropdown or checkbox / radio input. You just need to define your condition in input using HTML5 data-attribute.

Over and above that, you can also execute custom callback functions (onInit, onDestroy, onCheck etc).

Plugin Overview and Preview

Plugin: conditionize
Author: nk-o
Category: Text & Input
Published: 12 months ago
File Type: zip archive (HTML, CSS & JavaScript )
Package Size: 24 KB
Dependencies: jQuery 3.0 or Latest version
Last Modified:

Code Rating

[site_reviews_summary assigned_to=”post_id”]

How to Display Form Fields Based On Selection

1. To display form fields based on selection, we need to getting started with conditionize jQuery plugin. So, first of all load the jQuery JS library into your HTML document.

<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

2. After that, include plugin assets (from downloaded directory) in your web project.

<!-- conditionize CSS -->
<link rel="stylesheet" href="dist/style.css">
<!-- conditionize JS -->
<script src="dist/conditionize.min.js"></script>

3. Create HTML form with condition data like below:

<form class="my-form" action="#">
  <input type="text" name="text-control" placeholder="Type 'magic'">
  <div data-cond="[name=text-control] == magic">Magically show when text control contains 'magic' word.</div>

  <select name="select-control">
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three. Wow, you will see the new control below...</option>

  <div data-cond="[name=select-control] == 3">
      <input type="checkbox" name="checkbox-control">
      Is checked?
        <span data-cond="[name=checkbox-control] != true">Nope</span>
        <span data-cond="[name=checkbox-control]">Yep</span>
  <div data-cond="[name=select-control] == 3 && [name=checkbox-control] == true">
    <a href="https://github.com/nk-o/conditionize">GitHub</a>

4. Finally, add the follwing script to active the conditionize

$('.my-form').conditionize( {
  checkDebounce: 0,
  customToggle: function( $item, show ) {
    if ( show ) {
    } else {


Configuration Options to Display Form Fields Based on Selection

The following are some advanced configuration options to create jQuery based display form fields based on selection.

Option Default Type Description
selector [data-cond] String The selector for condition.


	selector : [data-cond],
conditionAttr data-cond String The HTML5 data attribute that will be checked for condition.


	conditionAttr : data-cond,
checkDebounce 150 Number Debounce timeout for better performance.


	checkDebounce : 150,
[site_reviews assigned_to=”post_id”]

Submit Your Review

[site_reviews_form assign_to=”post_id”]