ReactiveRaven / jqBootstrapValidation

A JQuery validation framework for bootstrap forms.
http://reactiveraven.github.io/jqBootstrapValidation
MIT License
1.35k stars 334 forks source link

Dynamic Validate Problem #212

Open gunaysirbudak opened 5 years ago

gunaysirbudak commented 5 years ago

Hi,

If the Create_user field is enabled, check the password and default_lang fields using the following code.

If Create_user is disabled, I'm canceling control of those fields.

However, when create_user becomes active and inactive, it always performs mandatory field control.

I'm waiting for your help and support.

`

    if(document.getElementById('user_create').checked == true)
    {
        $('#password').attr('required','required');
        $('#password').attr('data-validation-required-message','<?= lang('required_error'); ?>');
        $('#password').attr('minlength','6');
        $('#password').attr('data-validation-minlength-message','<?= lang('minlength_error'); ?>');
        $('#password').attr('aria-invalid','true');

        $('#default_lang').attr('required','required');
        $('#default_lang').attr('data-validation-required-message','<?= lang('required_error'); ?>');
        $('#default_lang').attr('aria-invalid','true');

        $("input,select,textarea").not("[type=submit]").jqBootstrapValidation();
        $('#user').removeAttr('style');

    }
    else
    {
        $("input,select,textarea").jqBootstrapValidation("destroy");
        $('#password').removeAttr('required');
        $('#password').removeAttr('data-validation-required-message');
        $('#password').removeAttr('minlength');
        $('#password').removeAttr('data-validation-minlength-message');
        $('#password').removeAttr('aria-invalid');

        $('#default_lang').removeAttr('required');
        $('#default_lang').removeAttr('data-validation-required-message');
        $('#default_lang').removeAttr('aria-invalid'); 

        $("input,select,textarea").not("[type=submit]").jqBootstrapValidation();

        $('#user').attr('style', 'display: none;');

    }`