一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

PHP jQuery表單,帶驗(yàn)證具體實(shí)現(xiàn)方法

 Email檢測(cè),密碼重復(fù)檢測(cè),可以用于表單發(fā)送的各種環(huán)境,例如發(fā)送反饋,注冊(cè)帳號(hào)

復(fù)制代碼 代碼如下:
<div id="container"> 
        <?if( isset($_POST['send']) && (!validateName($_POST['name']) || !validateEmail($_POST['email']) || !validatePasswords($_POST['pass1'], $_POST['pass2']) || !validateMessage($_POST['message']) ) ):?> 
                <div id="error"> 
                    <ul> 
                        <?if(!validateName($_POST['name'])):?> 
                            <li><strong>Invalid Name:</strong> We want names with more than 3 letters!</li> 
                        <?endif?> 
                        <?if(!validateEmail($_POST['email'])):?> 
                            <li><strong>Invalid E-mail:</strong> Stop cowboy! Type a valid e-mail please :P</li> 
                        <?endif?> 
                        <?if(!validatePasswords($_POST['pass1'], $_POST['pass2'])):?> 
                            <li><strong>Passwords are invalid:</strong> Passwords doesn't match or are invalid!</li> 
                        <?endif?> 
                        <?if(!validateMessage($_POST['message'])):?> 
                            <li><strong>Ivalid message:</strong> Type a message with at least with 10 letters</li> 
                        <?endif?> 
                    </ul> 
                </div> 
            <?elseif(isset($_POST['send'])):?> 
                <div id="error" class="valid"> 
                    <ul> 
                        <li><strong>Congratulations!</strong> All fields are OK ;)</li> 
                    </ul> 
                </div> 
        <?endif?> 

        <form method="post" id="customForm" action=""> 
            <div> 
                <label for="name">Name</label> 
                <input id="name" name="name" type="text" /> 
                <span id="nameInfo">What's your name?</span> 
            </div> 
            <div> 
                <label for="email">E-mail</label> 
                <input id="email" name="email" type="text" /> 
                <span id="emailInfo">Valid E-mail please, you will need it to log in!</span> 
            </div> 
            <div> 
                <label for="pass1">Password</label> 
                <input id="pass1" name="pass1" type="password" /> 
                <span id="pass1Info">At least 5 characters: letters, numbers and '_'</span> 
            </div> 
            <div> 
                <label for="pass2">Confirm Password</label> 
                <input id="pass2" name="pass2" type="password" /> 
                <span id="pass2Info">Confirm password</span> 
            </div> 
            <div> 
                <label for="message">Message</label> 
                <textarea id="message" name="message" cols="" rows=""></textarea> 
            </div> 
            <div> 
                <input id="send" name="send" type="submit" value="Send" /> 
            </div> 
        </form> 
    </div> 

validation.php

復(fù)制代碼 代碼如下:
<?php 
    function validateName($name){ 
        //if it's NOT valid 
        if(strlen($name) < 4) 
            return false; 
        //if it's valid 
        else 
            return true; 
    } 
    function validateEmail($email){ 
        return ereg("^[a-zA-Z0-9]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$", $email); 
    } 
    function validatePasswords($pass1, $pass2) { 
        //if DOESN'T MATCH 
        if(strpos($pass1, ' ') !== false)
            return false;
        //if are valid
        return $pass1 == $pass2 && strlen($pass1) > 5;
    }
    function validateMessage($message){
        //if it's NOT valid 
        if(strlen($message) < 10) 
            return false; 
        //if it's valid 
        else 
            return true; 
    } 
?> 

php技術(shù)PHP jQuery表單,帶驗(yàn)證具體實(shí)現(xiàn)方法,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲综合色婷婷在线观看 | 欧美成年黄网站色高清视频 | 久久久久久一级毛片免费无遮挡 | 国产成人福利精品视频 | 91在线精品老司机免费播放 | 成人免费一区二区三区 | 91麻豆精品国产高清在线 | 国产页 | 五月婷婷网站 | 久久亚洲国产成人精品性色 | 精品国产福利片在线观看 | 久久亚洲aⅴ精品网站婷婷 久久亚洲不卡一区二区 | 国产在线观看91精品 | 精品亚洲一区二区三区 | 亚洲成人中文 | 久久九九精品一区二区 | 久久er国产精品免费观看8 | 亚洲国产成人精品小蝌蚪 | 免费黄色欧美 | 亚洲一二三区久久五月天婷婷 | aabb片免费看 | 五月婷婷伊人 | 99久久香蕉国产线看观香 | 免费韩国美女爽快一级毛片 | 欧美日在线观看 | 伊人久久综合视频 | 欧美成人aaaa免费高清 | 久久久久久久久久综合情日本 | 国产精品极品美女自在线观看免费 | 91成人在线免费视频 | 2018狠狠操| 色婷婷99综合久久久精品 | 国产一区不卡 | 色哟哟在线观看视频高清大全 | 男人猛桶女人下面视频国产 | 精品国免费一区二区三区 | 中文字幕第13亚洲另类 | 亚洲欧美另类精品久久久 | 91久久99久91天天拍拍 | 色播影院性播免费看 | 五月婷婷六月婷婷 |