亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

js彈窗驗證失敗

js彈窗驗證失敗

陪伴而非守候 2018-10-19 14:11:49
之前這樣打代碼是有,沒有輸入用戶名是有彈窗出來提示的,現在沒有。<script>function s(){    var a = document.getElementById('name1').value;    var b = document.getElementById('pw1').value;     var c = document.getElementById('pw2').value;    if (a== ""||a== "null") {         alert("請好好輸入用戶名!");        return false;     }    else if (b== ""||b== "null") {         alert("請正確填寫密碼!");        return false;     }    else if (c!=b || c== "null") {         alert("請輸入與上面一樣的密碼");        return false;     }    else{        return true;     } } </script>放在了head標簽里面,因為是初學,很多不是很明白,在這先謝過幫我的人。
查看完整描述

1 回答

?
滄海一幻覺

TA貢獻1824條經驗 獲得超5個贊

<!DOCTYPE html>

<html>

    <head>

        <meta charset="utf-8" />

        <title>debug</title>

        <script>

        function s(){

            var a = document.getElementById('name1').value;

            var b = document.getElementById('pw1').value;

            var c = document.getElementById('pw2').value;

            if (a == ""|| a == "null") {

            alert("請好好輸入用戶名!");

            return false;

            }

            else if (b == ""|| b == "null") {

            alert("請正確填寫密碼!");

            return false;

            }

            else if (c != b || c == "null") {

            alert("請輸入與上面一樣的密碼");

            return false;

            }

            else{

            return true;

            }

               }

         </script>

    </head>

    <body>

    用戶名:<input id="name1" type="text" value="" /><br />

    輸入密碼:<input id="pw1" type="password" value="" />

    <br />

    再次輸入密碼:<input id="pw2" type="password" value="" /><br />

    <input onclick="s()" type="button" value="確定" />

    <!--代碼方面是可以執行的 是不是 你 html 方面 哪里 弄錯了 -->

</body>

</html>


查看完整回答
反對 回復 2018-11-21
  • 1 回答
  • 0 關注
  • 666 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號