
第一步进行新增验证

第二步进行修改模态框 验证信息没有消除 且表单数据被缓存

相关推荐:《bootstrap入门教程》
模态框代码:新增修改共用一个模态框
js代码
//验证设置 $(function(){ $("#form1").bootstrapValidator({ feedbackIcons: { valid:"glyphicon glyphicon-ok", invalid:"glyphicon glyphicon-remove", validating:"glyphicon glyphicon-refresh" }, fields : { "unitName" : { validators : { notEmpty : { message : '单位名称不能为空' } } } } }); }); //重置表单数据 $(function() { $("#myModal").on('hide.bs.modal',function() { //关闭后重置表单数据 $("#form1").data('bootstrapValidator').resetForm(); }); $("#myModal").on('show.bs.modal',function() { //打开前重置表单数据 $("#form1").data('bootstrapValidator').resetForm(); }); }); function save() { //保存前开启验证 $("#form1").bootstrapValidator("validate"); if($("#form1").data("bootstrapValidator").isValid()){ $.ajax({ url : "${path}/center/unit/save.action", data : $('#form1').serialize(), type : "post", dataType : "json", beforeSend : function() { // loading show }, success : function(result) { if (result.success) { search(); alert(result.message); //关闭模态框 $('#myModal').modal('hide'); } else { alert(result.message); } }, complete : function() { }, error : function(data) { alert("error"); } }); }}
最终解决效果


Das obige ist der detaillierte Inhalt vonbootstrap的缓存怎么处理. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!
string zu int
So verwenden Sie den Scannow-Befehl
Ihr Computer kann nicht normal gestartet werden
Was bedeuten B-Seite und C-Seite?
Was ist der Unterschied zwischen Golang und Python?
Bitcoin-Handelsplattform
Warum startet mein Telefon ständig neu?
Der Unterschied zwischen Tastendruck und Tastendruck