您好,登錄后才能下訂單哦!
$.metadata.setType("attr", "vld");
$.validator.addMethod("username", function(value) {
var p = /^[0-9a-zA-Z\u4e00-\u9fa5\.\-@_]+$/;
return p.exec(value) ? true : false;
}, "Please enter only letters,digits,chinese and '_','-','@'");
$.metadata.setType("attr", "vld");
$.validator.addMethod("username", function(value) {
var p = /^[0-9a-zA-Z\u4e00-\u9fa5\.\-@_]+$/;
return p.exec(value) ? true : false;
}, "只能輸入字母、數字、中文和'_','-','@'符號");
jQuery.validator.addMethod("isMobile", function(value,element) {
var length = value.length;
var mobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
return this.optional(element) || mobile.test(value);
}, "請正確填寫您的手機號碼");
jQuery.validator.addMethod("isTel", function(value,element) {
var length = value.length;
var tel = /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
return this.optional(element) || tel.test(value);
}, "請正確填寫您的固定電話號碼");
jQuery.validator.addMethod("isPhone", function(value,element) {
var length = value.length;
var mobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
var tel = /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
return this.optional(element) || (tel.test(value) || mobile.test(value));
}, "請正確填寫您的聯系電話");
jQuery.validator.addMethod("isIdCardNo", function(value,element) {
var length = value.length;
//***正則表達式(15位)
var isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{2}(\d|X|x)$/;
//***正則表達式(18位)
var isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}(\d|X|x)$/;
return this.optional(element) || (isIDCard1.test(value) || isIDCard2.test(value));
}, "請正確填寫您的***號碼");
jQuery.validator.addMethod("isZipCode", function(value,element) {
var length = value.length;
var zipCode = /^[1-9]{1}(\d+){5}$/;
return this.optional(element) || zipCode.test(value);
}, "請正確填寫您的郵政編碼");
jQuery.validator.addMethod("isEmail", function (value, element) {
var mail = /^[a-z0-9._%-]+@([a-z0-9-]+\.)+[a-z]{2,4}$/;
return this.optional(element) || (mail.test(value));
}, "郵箱格式不對");
<form class="form b-mar-b-20" id="VipApply_AddForm" action="/addVipApply.jspx">
<span class="form-item-name">用戶名<span class="c-red">*</span></span>
<input type="text" class="input-text" id="loginName" name="loginName" vld=" {required:true,rangelength:[3,20],username:true,messages:{required:'請輸入用戶 名',rangelength:'用戶名由3到14位的中文字符、英文字母、數字組成'}}" />
</form>
$("#VipApply_AddForm").validate({
submitHandler: function(form) { //通過之后回調
$.post("${base}/addVipApply.jspx",
$('#VipApply_AddForm').serialize(),
function(data){
if(data.status==0){
alert("VIP申請已提交,請耐心等待審核結果!");
location.href='${base}/hymsa/';
}else if(data.status==1) {
alert("驗證碼錯誤");
$("#vipApplyCaptcha").click();
}
},'json');
},
invalidHandler: function(form, validator) { //不通過回調
return false;
}
});
});
@RequestMapping(value = "**/addVipApply.jspx")
public void addVipApply(VipApplyEntity entity,String captcha, HttpServletRequest request,HttpServletResponse response, ModelMap model) throws JSONException {
JSONObject json = new JSONObject();
try {
this.vipApplyService.save(entity);
json.put("status", 0);
} catch (Exception e) {
json.put("status", 1);
e.printStackTrace();
}
ResponseUtils.renderJson(response, json.toString());
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。