/** * 数据简单校验 */ function checkData (formId) { var check = true; var emailReg = new RegExp("^[a-z0-9]+([._\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$"); //验证邮箱 var phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/; $("#"+formId+" input[type!='radio']").each(function () { if($(this).val() == "" || $(this).val() == null || $(this).val() == undefined) { layer.tips('不能为空', '#'+$(this).attr("id"), { tips : [ 2, '#ffcc00' ], time:1000 }); check = false; return false; }else if($(this).attr("name") == "email") { if(!emailReg.test($(this).val())) { layer.tips('邮箱格式不正确', '#'+$(this).attr("id"), { tips : [ 2, '#ffcc00' ], time:1000 }); check = false; return false; } }else if($(this).attr("name") == "phone") { if(!phoneReg.test($(this).val())) { layer.tips('手机格式不正确', '#'+$(this).attr("id"), { tips : [ 2, '#ffcc00' ], time:1000 }); check = false; return false; } } }) return check; }