Java脚本电子邮件验证 [英] java script email validation

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

问题描述

你好
我想使用Java脚本验证电子邮件-ID.
如果有的话,请给我发送代码.

提前thnx

hello
i want to validate email - id using java script..
plz send me the code if anyone is having.

thnx in advance

推荐答案

在此处找到一些链接

http://www.w3schools.com/js/js_form_validation.asp [ http://www.smartwebby.com/dhtml/email_validation.asp [ http://www.usingjavascript.com/scripts/validateemail.html [
Find some links here

http://www.w3schools.com/js/js_form_validation.asp[^]

http://www.smartwebby.com/dhtml/email_validation.asp[^]

http://www.usingjavascript.com/scripts/validateemail.html[^]


<html>
    <head>
        <IMG SRC="I:/New Folder/JavaScriptExample/Javascriptexample/index.jpg" WIDTH="125" HEIGHT="94" BORDER="0" ALT="">
    <title>
        E-mail validation
    </title>

    <script type="text/javascript">
function emailvalidation(field,msg1)
{
        with(field)
            {
                apos=value.indexOf("@");
                dotpos=value.lastIndexOf(".");
                if(apos<1||dotpos-apos<2)

                {

                    alert(msg1);return false;

                }

                else

                {

                    return true;

                }

        }

}



function validform(thisform)

    {

        with(thisform)

        {

            if (emailvalidation(email,"Pls Insert valid E-mail")==false)

            {

                email.focus();return false;

            }

        }

    }

    </script>
    </head>
<body>

<form action="submit.htm" onsubmit="return validform(this);" method="post">
    Email:
<input type="text" name="email" size="30">
<input type="submit" value="Submit">
</form>
</body>
</html>


[ ^ ]似乎是您迈出的合乎逻辑的第一步.当然,它只会检查电子邮件地址的格式是否正确,而不是是否可以正常使用.只是一个正则表达式.
This[^] seems like the logical first step for you to take. Of course, it will just check if the email address is well formed, not if it will work. It''s just going to be a regex.


这篇关于Java脚本电子邮件验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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