Last active
February 8, 2018 16:18
-
-
Save Alireza2n/cb263722adaf64261482b62c2d1b7960 to your computer and use it in GitHub Desktop.
dynamically add and remove required based on radio select using jqueryvalidation library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$("#approval_form").validate(); | |
$('input[type=radio][name=status]').on('change', function () { | |
switch ($(this).val()) { | |
case '1': | |
console.log('case 1'); | |
$("#id_notes").rules('remove', 'required'); | |
break; | |
case '0': | |
console.log('case 0'); | |
$("#id_notes").rules('add', { | |
required: true | |
}); | |
break; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment