我的验证表单 Dosent 工作,我不知道为什么



我的验证表单根本不起作用,我不知道为什么,似乎没问题

     function Validator(){
            if(document.shahab_Form.TheCheckBox.checked)
            {
                alert("it's already Checked my Friend!");
            }
            else
            {
             alert("no it's not checked my friend");
            }
        }
    <form name="Shahab_Forms">
            <input type="checkbox" name="TheCheckBox"/>
            <input type="button" value="Press Me" onclick="Validator();"/> 
    </form>
  

JavaScript 区分大小写。 Shahab_Formsshahab_forms不同。代码中有 2 个错误:

1)案例敏感性,即shahab_FormsShahab_Forms

2)你打错了字:shahab_Form。你最后错过了"s"。

以下是您的工作代码

 function Validator(){
            if(document.Shahab_Forms.TheCheckBox.checked)
            {
                alert("it's already Checked my Friend!");
            }
            else
            {
             alert("no it's not checked my friend");
            }
        }
   
 <form name="Shahab_Forms">
            <input type="checkbox" name="TheCheckBox"/>
            <input type="button" value="Press Me" onclick="Validator();"/> 
    </form>

     function Validator(){
            if(document.shahab_Form.TheCheckBox.checked)
            {
                alert("it's already Checked my Friend!");
            }
            else
            {
             alert("no it's not checked my friend");
            }
        }
    <form name="Shahab_Forms">
            <input type="checkbox" name="TheCheckBox"/>
            <input type="button" value="Press Me" onclick="Validator();"/> 
    </form>
  

相关内容

最新更新