$(document).ready(function() { $.formValidator.initConfig({ theme : "127", submitOnce : false, errorFocus : false, onError : function(msg, obj, errorlist) { }, ajaxPrompt : '有数据正在异步验证,请稍等...' }); $("#reporterName").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请输入报案人姓名", defaultValue : "" }).inputValidator({ min : 1, max : 200, onError : "请输入报案人姓名" }); $("#reporterPhoneNumber").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "请填写在投保申请上所留的电话号码", onCorrect : "", onShowFixText : "请输入报案人联系电话", defaultValue : "" }).inputValidator({ min : 1, max : 20, onError : "请输入报案人联系电话" }).functionValidator({ fun : msg = isPhone, onError : msg }); $("#insuredName").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请输入出险人姓名", defaultValue : "" }).inputValidator({ min : 1, max : 200, onError : "请输入出险人姓名" }); $("#insuredPhoneNumber").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "若固定电话按“区号-电话”输入", onCorrect : "", onShowFixText : "请输入出险人联系电话", defaultValue : "" }).inputValidator({ min : 1, max : 20, onError : "请输入出险人联系电话" }).functionValidator({ fun : msg = isPhoneD , onError : msg }); $("#insuredSex").formValidator({ onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请选择性别", defaultValue : "" }).inputValidator({ min : 1, max : 20, onError : "请选择性别" }); $("#reporterRelation").formValidator({ onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请选择与出险人关系", defaultValue : "" }).inputValidator({ min : 1, max : 20, onError : "请选择与出险人关系" }); $("#accidentTime").datepicker({ changeMonth: true, changeYear: true, showOn: 'focus', // buttonImage: '../../../images/res/cal.gif', // buttonImageOnly: true, minDate: '-2y', maxDate: '+0d', onClose : function(date,obj){$("#accidentTimeTip").removeClass();$("#accidentTimeTip").hide();} }); $('#accidentTime').datepicker('option', {dateFormat: "yy-mm-dd" }); $("#accidentTime").formValidator({ onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "", defaultValue : "" }).inputValidator({ min : 1, max : 12, onError : "请选择事故日期" }).functionValidator({ fun : isDate, onError : "请选择事故日期" }); $("#insuredId").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请输入出险人身份证号码", defaultValue : "" }).inputValidator({ min : 1, max : 18, onError : "请输入出险人身份证号码" }).functionValidator({ fun : msg = isCardID , onError : msg }); $("#hospital").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "", defaultValue : "" }).inputValidator({ min : 0, max : 200, onError : "请输入200以内的字符" }); $("#accidentPlace").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请输入事故地点", defaultValue : "" }).inputValidator({ min : 1, max : 300, onError : "请输入300以内的字符" }); $("#theAccident").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请输入事故经过", defaultValue : "" }).inputValidator({ min : 1, max : 1000, onError : "请输入1000以内的字符" }); $("#insuredStatus").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请输入出险人现状", defaultValue : "" }).inputValidator({ min : 1, max : 500, onError : "请输入500以内的字符" }); $("#costSituation").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "", defaultValue : "" }).inputValidator({ min : 0, max : 500, onError : "请输入500以内的字符" }); $("#remarks").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "", defaultValue : "" }).inputValidator({ min : 0, max : 100, onError : "请输入100以内的字符" }); $("#j_captcha").formValidator({ onShowFixText : "", onShowText : "", onShow : "", onFocus : "", onCorrect : "", onShowFixText : "请输入验证码", defaultValue : "" }).inputValidator({ min : 1, max : 200, onError : "请输入验证码" }); //在线报案 $("#saveBtn").click(function (e) { var pageIsValid = $.formValidator.pageIsValid(); if(!pageIsValid){ return; } var j_captcha=$("#j_captcha").val(); if(j_captcha.length != 4){ $("#j_captchaTip").html("请输入正确的验证码"); $("#j_captchaTip").addClass("onError"); $("#j_captchaTip").show(); return; } $("#saveBtn").addClass("register_but_o_f"); var formParams = {}; formParams = $("#ReportForm").values(); Newtouch.Ajax.sendParams({j_captcha:$("#j_captcha").val()}, "../../../jCaptche_check.check", function(data){ //验证码正确 if(data['_value']=="ok"){ Newtouch.Ajax.sendParams(formParams, "onlineReporter", function(data) { if(data['_value']=="OK"){ //转到理赔流程图页面 Newtouch.Direct.postDataWithForm("onlineReportResult.jsp"); }else{ //提交失败弹出层 $.unblockUI(); showBlockDiv("opendiv1"); document.getElementById('messageId1').innerHTML = "提交失败:"+data['_value']; $("#confirmId1").bind("click",closeBlockUI); } },function(err){ alert(err); }); }else{ $("#j_captchaTip").html("请输入正确的验证码"); $("#j_captchaTip").addClass("onError"); $("#j_captchaTip").show(); refreshCaptcha(); } }, function(err) { alert(err); }); }); $("#closeWindow").click(function(){ window.close(); }); }); function refreshCaptcha() { $('#captchaImg').attr('src','../../../images/captchaloadin.gif'); $('#captchaImg').hide().attr('src','../../../res/jcaptcha.jpg' + '?' + Math.floor(Math.random() * 100)).fadeIn(); } function isCardID(){ var E = $("#insuredId").val(); var A=0;var D=""; if(!/^\d{17}(\d|x)$/i.test(E)){ return "你输入的身份证长度或格式错误"; } E=E.replace(/x$/i,"a"); if(aCity[parseInt(E.substr(0,2))]==null){ return "你的身份证地区非法"; } sBirthday=E.substr(6,4)+"-"+Number(E.substr(10,2))+"-"+Number(E.substr(12,2)); var C=new Date(sBirthday.replace(/-/g,"/")); if(sBirthday!=(C.getFullYear()+"-"+(C.getMonth()+1)+"-"+C.getDate())){ return "身份证上的出生日期非法"; } for(var B=17;B>=0;B--){ A+=(Math.pow(2,B)%11)*parseInt(E.charAt(17-B),11); } if(A%11!=1){ return "你输入的身份证号非法"; } return true; } function isPhone(){ var reporterPhoneNumber = $("#reporterPhoneNumber").val(); if(reporterPhoneNumber.indexOf("-") == "-1"){ if(!/^(1)[0-9]{10}$/.test(reporterPhoneNumber)){ return "请输入正确的手机号"; } return true; }else{ if(!/^(([0+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/.test(reporterPhoneNumber)){ return "请输入正确的固定电话"; } return true; } } function isPhoneD(){ var insuredPhoneNumber = $("#insuredPhoneNumber").val(); if(insuredPhoneNumber.indexOf("-") == "-1"){ if(!/^(1)[0-9]{10}$/.test(insuredPhoneNumber)){ return "请输入正确的手机号"; } return true; }else{ if(!/^(([0+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/.test(insuredPhoneNumber)){ return "请输入正确的固定电话"; } return true; } } function isDate() { var str = $("#accidentTime").val(); var r = str.match(/^(\d{1,4})(-)(\d{1,2})\2(\d{1,2})$/); if(r==null)return false; var d= new Date(r[1], r[3]-1, r[4]); return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]); } function closeBlockUI(){ $.unblockUI(); }