bootstrapvalidator calibration, calibration reset clears
//保存 function saveAdmin(){ //开启验证 $('#saveadmin_form').data('bootstrapValidator').validate(); if(!$('#saveadmin_form').data('bootstrapValidator').isValid()){ return ; } //表单提交 $.ajax({ type: "POST", dataType : 'json', url: "<%=request.getContextPath()%>/user/saveUser.html?ma="+Math.random(), data: { "type" :"0", "id":$("#adminid").val(), "account":$("#edit_adminName").val(), "display_name":$("#edit_displayName").val(), "password":$("#edit_passwd").val(), "mail":$("#edit_Mail").val(), "role":$("#edit_role").val(), "desc":$("#edit_desc").val() }, success :function(json) { json = eval("("+json+")"); $("#editModal").modal("hide"); $("#dialog_content" ) .html (json.message); $ ( "#dialog_button_queren" ) .hide (); $ ( "#dialog_modal") Modal ( "Show." ); t.ajax.reload ( null , to true ) ; } }); } // initialize form validation $ (Document) .ready ( function () { formValidator (); }); / * ******************* ************* destruction validation check reset the focus here when modal hide and then reload verification ******************** ******************* * / // Modal verify the destruction of the reconstruction $ ( '# editModal'). on ( 'hidden.bs.modal',function() { $("#saveadmin_form").data('bootstrapValidator').destroy(); $('#saveadmin_form').data('bootstrapValidator', null); formValidator(); }); //form验证规则 function formValidator(){ $('#saveadmin_form').bootstrapValidator({ message: 'This value is not valid', feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'Refresh-glyphicon glyphicon' }, Fields: { // administrator name edit_adminName: { Message: 'name verification fails Administrators' , validators: { notEmpty: { Message: 'administrator name can not be empty' }, StringLength: { min: . 5 , max: 64 , Message: 'administrator name length must be between 6-64' } } } // Password edit_passwd: { Message: 'password authentication failed' , validators: { notEmpty: { Message: 'password can not be empty' }, StringLength: { min: 5 , max: 64 , Message: 'password length 5 to between 64 ' } / * , Identical: { Field:' edit_passwd1 ', Message:' two passwords do not match ' } * / } } // password confirmation edit_passwd1: { Message: 'Confirm Password authentication failed' , validators: { notEmpty: { Message: 'confirmation password can not be empty' }, Identical: { Field: 'edit_passwd' , Message: 'two passwords do not match' } } } // display name edit_displayName: { Message: ' user authentication failed name ' , validators: { notEmpty: { Message: 'display name can not be empty' }, StringLength: { min: . 5 , max: 128 , Message: 'display name length must be 6 to between 18 ' } } } // mail edit_Mail: { validators: { notEmpty: { Message: 'mailbox can not be empty' }, emailAddress: { Message: , 'mailbox format correct' }, StringLength: { max: 256 , Message: 'mailbox must be less than 256' } } } // NOTE edit_desc: { Message: 'Remarks authentication failed' Message: validators: { StringLength: { max: 256 ,'Remarks length must be less than 256' } } } } }); }