国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Verification information for PHP development registration page

Let’s take a look first, our registration page

reg.jpg


# From the picture above we can see that if the user’s username, password and verification code are not filled in, the user will be registered. , we do not allow it, these three items need to be verified, and the user’s password and confirmation password are entered twice differently, we do not allow it, this item is also our verification scope,


First we need to add JS events to our <form> form

<form action="" method="post"  name="myform" onsubmit=" return checkinput();" >

So that if our user submits the form, the js event will be triggered. Here is our JS judgment

<script type="text/javascript">
    function checkinput()
    {
        if(myform.name.value=="")
        {
            alert("請輸入用戶名");
            myform.name.focus();
            return false;
        }
        if (myform.pwd.value=="")
        {
            alert("請輸入密碼");
            myform.pwd.focus();
            return false;
        }
        if(myform.pwd.value != myform.pwdconfirm.value){
            alert("你輸入的兩次密碼不一致,請重新輸入!");
            myform.pwd.focus();
            return false;
        }
        if (myform.yzm.value=="")
        {
            alert("請輸入驗證碼");
            myform.yzm.focus();
            return false;
        }
    }
</script>

Submit when the information filled in by the user is incorrect, our JS event is triggered, and relevant prompt information is given to the user


The complete code for verification is as follows

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>PHP中文網(wǎng)</title>
    <script type="text/javascript">
        function checkinput()
        {
            if(myform.name.value=="")
            {
                alert("請輸入用戶名");
                myform.name.focus();
                return false;
            }
            if (myform.pwd.value=="")
            {
                alert("請輸入密碼");
                myform.pwd.focus();
                return false;
            }
            if(myform.pwd.value != myform.pwdconfirm.value){
                alert("你輸入的兩次密碼不一致,請重新輸入!");
                myform.pwd.focus();
                return false;
            }
            if (myform.yzm.value=="")
            {
                alert("請輸入驗證碼");
                myform.yzm.focus();
                return false;
            }
        }
    </script>
</head>
<body>
<form action="" method="post"  name="myform" onsubmit=" return checkinput();" >
    <div class="container">
        <div class="right">
            <h2>用戶注冊</h2>
            <p>用 戶 名:<input type="text" name="name" id="name"></p>
            <p>密  碼: <input type="password" name="pwd" id="pwd"></p>
            <p>確認密碼: <input type="password" name="pwdconfirm" id="pwdconfirm"></p>
            <p>驗 證 碼:<input type="text" name="yzm" id="yzm">
                <img src="yanzhengma.php" onClick="this.src='yanzhengma.php?nocache='+Math.random()" style="cursor:hand"></p>
            <p><button type="submit" value="注冊" >立即注冊</button></p>
        </div>
    </div>
</form>
</body>
</html>



Continuing Learning
||
<!doctype html> <html> <head> <meta charset="utf-8"> <title>PHP中文網(wǎng)</title> <script type="text/javascript"> function checkinput() { if(myform.name.value=="") { alert("請輸入用戶名"); myform.name.focus(); return false; } if (myform.pwd.value=="") { alert("請輸入密碼"); myform.pwd.focus(); return false; } if(myform.pwd.value != myform.pwdconfirm.value){ alert("你輸入的兩次密碼不一致,請重新輸入!"); myform.pwd.focus(); return false; } if (myform.yzm.value=="") { alert("請輸入驗證碼"); myform.yzm.focus(); return false; } } </script> </head> <body> <form action="" method="post" name="myform" onsubmit=" return checkinput();" > <div class="container"> <div class="right"> <h2>用戶注冊</h2> <p>用 戶 名:<input type="text" name="name" id="name"></p> <p>密  碼: <input type="password" name="pwd" id="pwd"></p> <p>確認密碼: <input type="password" name="pwdconfirm" id="pwdconfirm"></p> <p>驗 證 碼:<input type="text" name="yzm" id="yzm"> <img src="yanzhengma.php" onClick="this.src='yanzhengma.php?nocache='+Math.random()" style="cursor:hand"></p> <p><button type="submit" value="注冊" >立即注冊</button></p> </div> </div> </form> </body> </html>
submitReset Code