resetForm not working
in chrome v46,int resetForm() function unhighlight is no work,not remove errorClass. I tracked on line 468 the elements variable is an object,this should be the Array of it. http://jsfiddle.net/1t5nzoq2/
Thanks for reporting.
Just to make sure we are talking about the same problem:
- open http://jsfiddle.net/1t5nzoq2/
- click SAVE
- click RESET
-> expected: the form should render as on the initial page load -> actual: form control still has red borders and label still are rendered in red color Can you confirm that?
I get the same problem in FF43. Are you willing to provide a failling unit test?
Update: I just found a typo in your Fiddle which seems to be the culprit.
fixed version at http://jsfiddle.net/1t5nzoq2/
this
unhighlight: function (element, errorClass) {
$(element).closest('.control-group').removeClass(errorClass).removeClass('has-success');
},
should be
unhighlight: function (element, errorClass) {
$(element).closest('.form-group').removeClass(errorClass).removeClass('has-success');
},
right?
fixed version at http://jsfiddle.net/1t5nzoq2/
should be this instead: http://jsfiddle.net/1t5nzoq2/1/
whatever ;-)
@staabm I initially found the problem appeared in the model of the form, and then found that the form of the page is the case, I think that both sides are the same, so ... Please see my latest code,http://jsfiddle.net/1t5nzoq2/3/
- open modal
- click save button
- close modal
- open modal again
form control still has red borders and label still are rendered in red color.
@chaodongyue it is just a missconfiguration. The modal event you are using only executes after the modal components are already hidden. So for your validation to work, you have two alternatives:
- Instead of using the modal event "hidden.bs.modal", use "hide.bs.modal";
- Or overwrite the ignore property with an empty string to the validation configuration, see the code http://jsfiddle.net/1t5nzoq2/5/;
@staabm I don't know if this would be a bug or not, but shouldn't the validation message also be kept, since the ignore property is filtering the input that is hidden?
@dkrahn Thank you very much, I finally know what happened