Validform表单验证,但没用form提交,而是按钮ajax提交后,验证失效

qq_33653058 2016-10-13 10:48:30
<script>
$(document).ready(function(){
var demo = $("#register").Validform({
tiptype:2
});
})
</script>

//form内容
<form method="post" id="register">
<div class="left_frame2">
<div class="about_content">修改联系方式</div>
<hr width="350px" color="lightgray" style="margin-left:150px" />
<div class="about_tel"><label>原手机号:</label> <input type="text" class="input-text-1" errormsg="输入格式错误" nullmsg="请输入手机号码" datatype="m" name="tel" id="tel" ajaxurl="/property/tell/user" /></div>
<div class="inline-block"></div>
<div class="about_tel"><label>新手机号:</label> <input type="text" class="input-text-1" sucmsg="通过验证" errormsg="输入格式错误" nullmsg="请输入手机号码" datatype="m" name="tell" id="tell" placeholder="请输入手机号码" /></div>
<div class="inline-block" id="inline1"></div>
<div style="width: 350px;margin-top:-13px;">
<input style="margin:20px 0px 0px 180px; border-style: inset;" type="reset" value="重置" onclick="resets()"/>
<input style="margin:20px 0px 0px 50px; border-style: inset;" type="button" value="保存资料" onclick="sibmits()"/>

</div>
</div>
</form>

//保存资料按钮ajax请求;
function sibmits(){
var tell=$(".left_frame2 .about_tel #tell").val();
$.ajax({
url:"/property/insertUpdate/phone",
type:"post",
dataType:"json",
data:{"tell":tell},
success:function(data){
layer.alert('恭喜您,修改成功', {
skin: 'layui-layer-lan',
closeBtn: 0,
shift: 4 //动画类型
});
$('#register')[0].reset();
},
error:function(){
alert("error");
}
})
}
怎么在ajax中添加一个如果表单验证没通过,不执行的语句啊???
...全文
4728 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
堆栈科技 2018-04-17
  • 打赏
  • 举报
回复
if(demo.check()==false) { return; }
soonyolsd 2017-02-08
  • 打赏
  • 举报
回复
VALIDFORM有参数验证的方法http://www.cnblogs.com/dreamflycc/p/5073820.html 你既然都用了这个插件,为何还要自己写submit呢
fluor 2016-12-02
  • 打赏
  • 举报
回复
你看下后端接收参数是不是一个?
Go 旅城通票 2016-10-13
  • 打赏
  • 举报
回复
加红色那句看是否执行,自己同事检查这个函数js路径是否正确 function sibmits(){ alert(11)

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧