我写的验证方法要不只能验证邮箱存在不存在,要不验证输入是否为空!不能验证邮箱格式是否正确
验证邮箱的正则表达式是 /\w+@\w+.\w/
我的代码是
<script type="text/javascript">
$().ready(function (){
$("#zhanghao1").blur(function(){
$("#infor").empty();
var userName=$("#zhanghao1").val();
if(userName.length==0){
$("#infor").append("<h2>账号不能为空</h2>");
}else{
$.post("checkUserName.do",{userName : userName},function(data){
$("#infor").append("<h2>"+data+"</h2>");
});
}
});
});
</script>
账号:<input type="text" id="zhanghao1" name="userName"><div id="infor"></div>