function checkEmail(email) { var reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/; if(!reg.test(email)){ alert("邮箱格式不正确"); return false; } } function checkName(name) { var reg = /(?!^(\d+|[a-zA-Z]+|[~!@#$%^&*?]+)$)^[\w~!@#$%^&*?]{7,20}$/; if(!reg.test(name)){ alert("用户名格式不正确"); return false; } }