validator的验证
通常喜欢这么写验证
<form method="post" data-ajax="false" action="/Shppping/PlaceOrder" id="orderform"> <a class="btnpay" href="javascript:void(0)" onclick="return checkSubmit();" id="btnpay">支付</a> <a class="btncancel" id="btncancel" href="javascript:void(0)">取消</a> </form>
然后就是checksubmit方法
function checkSubmit() { var errorMsg = ""; var sj = $("#ordertime"); var sfz = $("#orderncerti"); var dyz = $("#ordernguideCard"); var lxs = $("#orderntravelAgency"); var smr = $("#ordername"); var sjh = $("#orderphone"); if (sj.length > 0 && sj.val() == "") { errorMsg = "请选择出行日期"; } else if (sjh.length > 0 && sjh.val() == "") { errorMsg = "手机号码不正确"; } else if (smr.length > 0 && smr.val() == "") { errorMsg = "请填写姓名"; } else if (sfz.length > 0 && sfz.val() == "") { errorMsg = "请填写身份证号"; } else if (dyz.length > 0 && dyz.val() == "") { errorMsg = "请填写导游证号"; } else if (lxs.length > 0 && lxs.val() == "") { errorMsg = "请填写旅行社名称"; } else if ($(".Ochooseno1.active").length == 0 || $(".Ochooseno2.active").length == 0) { errorMsg = "请选择支付方式"; } if (errorMsg != "") { alert(errorMsg); return false; } //$("#orderForm").submit(); alert("提交成功"); return false; //return true; }
再有就是validate.js的使用