使用测试功能验证java脚本中的电子邮件地址 [英] use the test function for validating of email address in java script

查看:96
本文介绍了使用测试功能验证java脚本中的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各个团体



我在java脚本中使用test函数检查用户输入的电子邮件地址...我的代码不起作用。



可以帮我吗?



感谢您的时间

html代码:

hi every body

I use "test" function in java script to check the email address is entered by user ... my code doesn't work .

can any body help me??

thanks for your time
html code:

<form action="" method="POST" name="frm1">
 <table>
         <tr>
            <td>
                 Email :
            </td>
            <td>
                <input type="text" name="user_email" />
            </td>
        </tr>
        

        <tr>         
            <td>
                <input type="submit" value="submit" onclick="validateEmail(user_email)"  />
            </td>
        </tr>
    </table>
 </form>



< br $> b $ b










<script language="JavaScript" type="text/javascript">

function validateEmail(email) { 
       //// email=document.forms["frm1"]["user_email"].value; // 

 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]1,3}.0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
     
 return re.test(email);

</script>

推荐答案

/;

return re.test(email);

< / script>


请参阅:

http://en.wikipedia.org/wiki/Regular_expression [ ^ ],

http://www.w3schools.com/jsref/jsref_obj_regexp.asp [ ^ ],

http://www.regular- expressions.info/tutorial.html [ ^ ],

http://www.regular-expressions.info/reference.html [ ^ ]。



请理解:常规异常相对容易编写,但令人惊讶的难以阅读和理解。这就是为什么从头开始编写它们比修复你在某处更容易的原因。


所以,如果你得到的正则表达式不适合你,创建你自己。或尝试寻找其他内容: http://bit.ly/14LMEL7 [ ^ ]。



-SA
Please see:
http://en.wikipedia.org/wiki/Regular_expression[^],
http://www.w3schools.com/jsref/jsref_obj_regexp.asp[^],
http://www.regular-expressions.info/tutorial.html[^],
http://www.regular-expressions.info/reference.html[^].

Please understand: Regular Exceptions are relatively easy to write but surprisingly hard to read and understand. That's why writing them from scratch is way easier then fixing one you got somewhere.

So, if the regular expression which you get somewhere don't work for you, create your own. Or try to find something else: http://bit.ly/14LMEL7[^].

—SA


这篇关于使用测试功能验证java脚本中的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆