JS 校驗函數 第二篇(輸入密碼一致性)

方法一:

Html代碼:

<form method = post action = "">
    <input type="password" id="input1">
    <input type="password" id="input2">
    <input type="button" value="test" οnclick="check()">
</form>

JavaScript代碼:

<script>
    function check()
    {
        with(document.all){
        if(input1.value!=input2.value)
        {
            alert("false")
            input1.value = "";
            input2.value = "";
        }
        else document.forms[0].submit();
    }
}
</script>

 

方法二:

Html代碼:

<form   name="theform">   
    <input   type="text"   id="pswc"   name="pswc">      
    <input   type="text"   id=psw   name="psw">   
    <input   type="button"   οnclick=alert(f1())>   
</form>

JavaScript代碼:

<script>    

function   f1()   
{   
    if(document.theform.pswc.value!=document.theform.psw.value   )   
    {   
        //alert(document.theform.pswc.value);   
        document.theform.pswc.focus();   
        return   false;   
    }   
   else   
   {   
       return   true;   
   }   
}   
</script>

 

方法三:

JavaScript代碼:

<script language="javascript">
<!--
function CheckForm()
if (document.form.PWD.value != document.form.PWD_Again.value) {
   alert("您兩次輸入的密碼不一樣!請重新輸入.");
   document.ADDUser.PWD.focus();
   return false;
}
   return true;
}
-->
</script>

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章