Bootstrap validator for modal doesnt reset Form

£可爱£侵袭症+ 提交于 2019-12-04 10:11:56

Try following code :

$('#contactform').bootstrapValidator('resetForm', true);

The hidden.bs.modal event is fired when the modal has finished being hidden from the user, So the form will be hidden And BoostarpValidator doesn't treat or validate by default the hidden fields.

So in order to reset your form when the modal being hidden, you should add:

excluded: ':disabled'

to your JS code.

Live example: http://jsfiddle.net/Arkni/ndpv76bk/

Reference:

EDIT

Your initialization of bootstrapValidator on your form should be like the following after adding the excluded option:

    $('#addNodeForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        excluded: ':disabled',   // <=== Adding the 'excluded' option
        fields: {
            nodename: {
                validators: {
                    notEmpty: {
                        message: 'Function name is required'
                    }
                }
            }
        }
    });

Try the below code at which substation you want to reset the form..

 $('#addNodeForm').trigger("reset");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!