验证电子邮件地址 [英] Validatiing email address
本文介绍了验证电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在用户注册和登录时验证电子邮件地址。
一位用户无法注册他的电子邮件地址的原因是这种格式:
example@so-lutions.co.za
也许问题在于我的验证表达。
我的代码:
HTML
< div class = 警告 > < 输入 type = email 名称 = 电子邮件 < /秒pan> id = email < span class =code-attribute> 占位符 = 电子邮件 必需 = required <?php getpostvalue('email'); ? > /> < / div > < pre lang = HTML >
JavaScript
< pre lang = xml>< script type = text / javascript>
jQuery( function (){
jQuery( < span class =code-string>#email)。validate({
表达式: if(VAL.match(/ ^ [^ \\ W] [a-zA-Z0-9 \\\\\\-\\。] +([a -Za-Z0-9\\_\\-\\。] +)* @ \\ [A-ZA-Z0-9 _] +(\\。[A-ZA -Z0-9 _] +)* \\。[a-zA-Z] {2,4} $ /))返回true;否则返回false;,
message: < br>请提供有效的电子邮件地址!!< / b>
});
});
< / script>
我们将不胜感激。
解决方案
/))返回true;否则返回false;,
消息: < br>请提供有效的电子邮件地址!!< / b>
});
});
< / script>
我们将不胜感激。
你没有在你的reg-ex的域名部分中包含连字符。建议以下内容包含它们:
/ ^ [^ \\W] [A-ZA-Z0-9\\_\\-\\。] +([A-ZA-Z0-9\\_\ \-\\] +)* @ \\ [A-ZA-Z0-9_\\ - 。] +(\\ [A-ZA-Z0-9_\\ - 。] +)* \\ [A-ZA-Z] {2,4}
/
I m validating email address when user register and login.
One user was not able to register cause of his email address was in this format:
example@so-lutions.co.za
Maybe the problem is on my expression of validating.
My code:
HTML
<div class="warn"> <input type="email" name="email" id="email" placeholder="Email" required="required"<?php getpostvalue('email'); ?>/> </div><pre lang="HTML">
JavaScript
<pre lang="xml"><script type="text/javascript">
jQuery(function(){
jQuery("#email").validate({
expression: "if (VAL.match(/^[^\\W][a-zA-Z0-9\\_\\-\\.]+([a-zA-Z0-9\\_\\-\\.]+)*\\@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*\\.[a-zA-Z]{2,4}$/)) return true; else return false;",
message: "<br>Please provide a valid email address!!</b>"
});
});
</script>
Your help will be appreciated.
解决方案
/)) return true; else return false;", message: "<br>Please provide a valid email address!!</b>" }); }); </script>
Your help will be appreciated.
You're not including hyphen characters in the domain name section of your reg-ex. Suggest the following to include them:
/^[^\\W][a-zA-Z0-9\\_\\-\\.]+([a-zA-Z0-9\\_\\-\\.]+)*\\@[a-zA-Z0-9_\\-]+(\\.[a-zA-Z0-9_\\-]+)*\\.[a-zA-Z]{2,4}
/
这篇关于验证电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文