欧美一区二区三区性视频_婷婷综合另类小说色区_亚洲av乱码一区二区三区林ゆな_天堂在线资源中文在线8_久久这里只有精品首页

妙網(wǎng)科技 妙網(wǎng)科技 首頁 妙網(wǎng)科技 網(wǎng)站開發(fā) 妙網(wǎng)科技 JQuery郵箱驗(yàn)證完整代碼

JQuery郵箱驗(yàn)證完整代碼

所屬欄目: 網(wǎng)站開發(fā) | 更新時(shí)間:2016-4-27 | 閱讀:4365 次

<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("郵箱格式不正確,請(qǐng)重新填寫");
                        $(this).focus();
                    }
                    else {
                        $("#spinfo").text('');
                        $("#spinfo").append("<img src=images/onSuccess.gif />");
                        state=true;
                    }
                }
            })
        })
    </script>
</head>
<body>
 郵箱<input id="txtEmail" type="text" value="輸入郵箱" class="txtbackcolor" /><span id="spinfo"></span><br /></body>

下面就是程序運(yùn)行時(shí)的頁面;

當(dāng)我鼠標(biāo)點(diǎn)擊郵箱的文本框時(shí),文本框里面的字消失;

當(dāng)我什么也不填寫時(shí),就會(huì)出現(xiàn)提示信息;

下面是我隨便寫的字母,不符合郵箱格式,彈出錯(cuò)誤提示;

下面是最后的頁面,當(dāng)我輸入的郵箱的格式正確時(shí),后面的提示信息變成一張圖片。

?