$(function(){ $("#sOK").click(sOKsOK); }); function sOKsOK(){ var companyname = $("#companyname").val(); var years = $("#years").val(); var idcard1 = $("#idcard1").val(); var taxidcard = $("#taxidcard").val(); var frname = $("#frname").val(); var frid = $("#frid").val(); var regyears = $("#regyears").val(); var lastyeartimes = $("#lastyeartimes").val(); var lastyeartotal = $("#lastyeartotal").val(); var lastsales = $("#lastsales").val(); var currenttime = $("#currenttime").val(); var currenttotal = $("#currenttotal").val(); var linkname = $("#linkname").val(); var linktel = $("#linktel").val(); var data = { companyname:companyname, years:years, idcard1:idcard1, taxidcard:taxidcard, frname:frname, frid:frid, regyears:regyears, lastyeartimes:lastyeartimes, lastyeartotal:lastyeartotal, lastsales:lastsales, currenttime:currenttime, currenttotal:currenttotal, linkname:linkname, linktel:linktel } var dataTitle = { companyname:"公司名称", years:"成立年数", idcard1:"营业执照号码", taxidcard:"税务登记证号码", frname:"法人代表姓名", frid:"法人代表身份证号", regyears:"在本网站注册年数", lastyeartimes:"上年中标次数", lastyeartotal:"上年中标总金额", lastsales:"公司上年销售收入", currenttime:"公司当前贷款总笔数", currenttotal:"公司当前贷款总金额", linkname:"联系人姓名", linktel:"联系人手机" } $e = 0; $key = ""; for (var key in data){ //alert(key + data[key]); data[key] = $.trim(data[key]); if (data[key] == ""){ $e = 1; $key = key; break; } } if ($e == 1){ alert("【" + dataTitle[$key] + "】为必填项,请按要求填写。"); $("#" + $key).focus(); return false; } if (isNaN(years)){ alert("【成立年数】请输入数字,如果不满1年,请输入0。"); $("#years").focus().select(); return false; } if (isNaN(regyears)){ alert("【在本网站注册年数】请输入数字,如果小于1年,请输入0。"); $("#regyears").focus().select(); return false; } if (isNaN(lastyeartimes)){ alert("【上年中标次数】请输入数字"); $("#lastyeartimes").focus().select(); return false; } if (isNaN(lastyeartotal)){ alert("【上年中标总金额】请输入数字"); $("#lastyeartotal").focus().select(); return false; } if (isNaN(lastsales)){ alert("【公司上年销售收入】请输入数字"); $("#lastsales").focus().select(); return false; } if (isNaN(currenttime)){ alert("【公司当前贷款总笔数】请输入数字"); $("#currenttime").focus().select(); return false; } if (isNaN(currenttotal)){ alert("【公司当前贷款总金额】请输入数字"); $("#currenttotal").focus().select(); return false; } var patrn = /^[\w]{1,30}$/; if (!patrn.exec(idcard1)){ alert("营业执照号码 格式错误") $("#idcard1").focus().select(); return false; } patrn = /^[\w]{1,30}$/; if (!patrn.exec(taxidcard)){ alert("税务登记证号码 格式错误") $("#taxidcard").focus().select(); return false; } patrn = /^[\dxX]{18}$/; if (!patrn.exec(frid)){ alert("法人身份证号码 格式错误,请输入18位身份证号码。") $("#frid").focus().select(); return false; } patrn = /^[\d]{11}$/; if (!patrn.exec(linktel)){ alert("联系人手机 格式错误,请输入11位联系人手机号码。") $("#linktel").focus().select(); return false; } // 入库 for (var key in data){ data[key] = escape(data[key]); } url = "enter.shtml" $("#sOK").val("数据提交中……").attr("disabled", true); $.ajax({ url:url, type:"POST", data:data, success: function(msg){ msg = unescape(msg); var d = $.parseJSON(msg); alert(d.msg); }, error:function(msg){ alert("E:" + msg.responseText); }, complete:function(msg){ $("#sOK").val("提交").attr("disabled", false); } }); return false; }