Products
GG网络技术分享 2025-03-18 16:14 10
我写的验证方法要不只能验证邮箱存在不存在,要不验证输入是否为空!不能验证邮箱格式是否正确
验证邮箱的正则表达式是 /\\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>
$(\\\"#zhanghao1\\\").blur(function () {$(\\\"#infor\\\").empty();
var userName = $(\\\"#zhanghao1\\\").val();
if (/^\\w+@\\w+.\\w$/.test(userName)) {
$(\\\"#infor\\\").append(\\\"<h2>账号不正确</h2>\\\");
} else {
$.post(\\\"checkUserName.do\\\", { userName: userName }, function (data) {
$(\\\"#infor\\\").append(\\\"<h2>\\\" + data + \\\"</h2>\\\");
});
}
});
介绍一个正则表达式图形化工具,当你无法抽象理解所看到的正则表达式时,这个工具十分有用。
Demand feedback