formValidation手动ajax提交
基本的示例代码$("#artAdd-from").formValidation({//配置语言locale: "zh_CN",//验证字段fields: {title: {validators: {notEmpty: true,
·
基本的示例代码
$("#artAdd-from").formValidation({
//配置语言
locale: "zh_CN",
//验证字段
fields: {
title: {
validators: {
notEmpty: true,
stringLength: {
max: 150,
message: "标题长度最大为150个字符"
},
}
}
}
}).on('success.form.fv', function (e) {
// 阻止表单提交
e.preventDefault();
$.ajax({
url: "{{route('home.article.update',$article)}}",
type: 'PUT',
data: {
menu: is_Empty($("#vditor .vditor-outline .vditor-outline__content").html()) ? 0 : 1,
title: $("textarea[name='title']").val(),
content: vditor.getValue(),
}
}).then(({status, msg, url}) => {
if (status) {
notify(msg)
} else {//成功
//清除富文本的内容
vditor.clearCache();
//清空页面改变的询问框
refreshUnLock();
//页面重定向
redirectUrl(url);
}
})
});
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)