<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title>04checkEmail.html</title>

    <script>

        function chkPwd() {

            var thePwd = document.getElementById("idPwd").value;

            var flag1 = false, flag2 = false;

 

            if (thePwd == "")

                alert("不可空白");

            else if(thePwd.length>=6){

                for (i = 0; i < thePwd.length; i++) {

                    var theChar = thePwd.substr(i, 1).toUpperCase();

                    //var theChar = thePwd[i].toUpperCase();

                    if ("A" <= theChar && theChar <= "Z")

                        flag1 = true;

                    else if (0<= theChar && theChar<=9)

                        flag2 = true;

                    if (flag1 == true && flag2 == true)

                        break;

                }

                if (flag1 && flag2)

                    alert("可以使用");

                else

                    alert("密碼須包含至少一個字母與一個數字")

            }

            else

            alert("長度不正確")

 

        }

    </script>

</head>

<body>

    Password:<input type="password" id="idPwd" size="6"/><br/>

    Email:<input type="text" id="idEmail" />

    <br />

    <input type="button" value="checkPwd" onclick="chkPwd();" />

</body>

</html>

 

arrow
arrow
    全站熱搜

    乙方 發表在 痞客邦 留言(0) 人氣()