zoukankan      html  css  js  c++  java
  • jQuery邮箱验证

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <style type="text/css">
        .txtbackcolor
        {
            background-color:#eee;
            }
        </style>
        <script src="jquery-1.9.1.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                var state = false;
                $('#txtEmail').focus(function () {
                    if (state == false) {
                        $(this).val('');
                    }
                })
                $('#txtEmail').blur(function () {
                    if ($(this).val() == '') {
                        $('#spinfo').text('邮箱不能为空');
                        $(this).focus();
                    }
                    else {
                        if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test($(this).val()) == false) {
                            $('#spinfo').text('邮箱格式不正确,请重新输入');
                            $(this).focus();
                        }
                        else {
                            $('#spinfo').text('');
                            $('#spinfo').append('<img src=images/onSuccess.gif/>');
                            state = true;
                        }
                    }
                })


            })
        </script>
    </head>
    <body>
    邮箱<input type="text" id="txtEmail" value="输入邮箱" class="txtbackcolor" /><span id="spinfo"></span><br />
    电话<input type="text" id="txtPhone" />
    </body>
    </html>

  • 相关阅读:
    2021软件工程-第一周作业01准备工作
    String.matches()的用法
    Idea使用JSP出现404问题---已解决
    如何解决Tomcat启动闪退现象(环境配置没问题)
    解决启动java的web项目时端口占用问题
    IntelliJ IDEA 连接数据库 详细过程-包含使用jdbc连接数据库
    ApplicationContextAware接口认识
    RestTemplate 服务间接口调用
    maven相关
    FastJson:json字符串与Java对象转换
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3038701.html
Copyright © 2011-2022 走看看