$(function(){ $("#submit").click(function(){ if(confirm("是否确定要修改信息?")) { $("#tip").html(""); //验证输入的一些字段是否正确 var qq = $("#qq").val(); var skype = $("#skype").val(); var workUnit = $("#workUnit").val(); var school = $("#school").val(); var operationEmail = $("#operationEmail").val(); var cellphone = $("#cellphone").val(); if(qq != "" && qq.length > 20) { $("#tip").html("QQ号码过长"); return false; } if(skype != "" && skype.length > 20) { $("#tip").html("skype过长"); return false; } if(workUnit != "" && workUnit.length > 100) { $("#tip").html("工作单位过长"); return false; } if(school != "" && school.length > 100) { $("#tip").html("毕业院校过长"); return false; } if(operationEmail != "") { if(operationEmail.legth > 50) { $("#tip").html("邮箱地址过长"); return false; } var regEmail = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; if(!regEmail.test(operationEmail)) { $("#tip").html("邮箱格式不正确"); return false; } } if(cellphone != "") { var reg = /^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/; if(cellphone.length != 11 || !reg.test(cellphone)) { $("#tip").html("电话格式不正确"); return false; } } return true; } else { return false; } }); });
?