gpt4 book ai didi

javascript - jQuery 的实时电子邮件验证不起作用,我找不到错误

转载 作者:行者123 更新时间:2023-12-02 20:04:17 25 4
gpt4 key购买 nike

这是代码,我找不到错误。背景图像来自本地目录,与 jQuery 库相同。我已经测试了这些路径,它们都很好。不知怎的,有些东西不起作用,我无法找出答案。

<html>
<head>

<script type="text/javascript" src="/myform/js/jquery.js"></script>
<script type="text/javascript">

function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]+$/);
return pattern.test(emailAddress);
}

$(document).ready(function() {
 
$("#validate").keyup(function(){
var email = $("#validate").val();
 
if(email != 0)
{
if(isValidEmailAddress(email))
{
 
$("#validEmail").css({ "background-image": "url('/myform/logos/validyes.png')" });
 
} else {
 
$("#validEmail").css({ "background-image": "url('/myform/logos/validno.png')" });
 
}
 
} else {
 
$("#validEmail").css({ "background-image": "none" });
 
}
});
});

</script>
<style>
#validEmail
{
margin-top: 4px;
margin-left: 9px;
position: absolute;
width: 16px;
height: 16px;
}
</style>
</head>
<body>


<div><input type=”email” id=”validate” width=”50”><span id=”validEmail”></span></div>
</body>
</html>

最佳答案

尝试更换

if(email != 0)

if(email.length != 0)

关于javascript - jQuery 的实时电子邮件验证不起作用,我找不到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7643513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com