Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery验证不起作用。这是不正确的_Javascript_Jquery_Jquery Validate - Fatal编程技术网

Javascript jquery验证不起作用。这是不正确的

Javascript jquery验证不起作用。这是不正确的,javascript,jquery,jquery-validate,Javascript,Jquery,Jquery Validate,下面是JSP页面的附加源代码。我不知道为什么我的验证框架不起作用 有没有人能用以前的经验来帮助我 每当我试图点击提交按钮而不点击选择单选按钮时。它应该给我一个验证问题。但它不起作用 不知道我的剧本出了什么问题吗 你能帮我复习一下吗 HTML代码: <form method="post" id="identityVerification"> <div class="error-message" id="error-message1" style="

下面是JSP页面的附加源代码。我不知道为什么我的验证框架不起作用

有没有人能用以前的经验来帮助我

每当我试图点击提交按钮而不点击选择单选按钮时。它应该给我一个验证问题。但它不起作用

不知道我的剧本出了什么问题吗

你能帮我复习一下吗

HTML代码:

<form method="post" id="identityVerification">
                <div class="error-message" id="error-message1" style="display:none;">
                    <p id="err_cars" style="font-size:13px;"></p>
                    <p id="err_street" style="font-size:13px;"></p>
                </div><br/>
                <div>
                    <p style="padding-bottom:15px; font-size:13px;">Which of the following car is registered under your name in state of Washington?</p>
                                <input type="radio" name="questions[0].answer" value="Ford Focus" id="questions[0].answer_0"></input>
                                <label for="questions[0].answer_0">Ford Focus</label>
                                <input type="radio" name="questions[0].answer" value="Chevy Aveo" id="questions[0].answer_1"></input>
                                <label for="questions[0].answer_1">Chevy Aveo</label>
                                <div class="clear"></div>
                                <input type="radio" name="questions[0].answer" value="Toyota Celica" id="questions[0].answer_2"></input>
                                <label for="questions[0].answer_2">Toyota Celica</label>
                                <input type="radio" name="questions[0].answer" value="None of these" id="questions[0].answer_3"></input>
                                <label for="questions[0].answer_3">None of these</label>
                                <div class="clear"></div>
                </div>
                <br/><br/><br/><br/>

                <div>
                    <p style="padding-bottom:15px; font-size:13px;">Which of the following street are you currently residing or have previously resided?</p>
                                <input type="radio" name="questions[1].answer" value="1 Grape Vine" id="questions[1].answer_0"></input>
                                <label for="questions[1].answer_0">1 Grape Vine</label>
                                <input type="radio" name="questions[1].answer" value="23 Main Street" id="questions[1].answer_1"></input>
                                <label for="questions[1].answer_1">23 Main Street</label>
                                <div class="clear"></div>
                                <input type="radio" name="questions[1].answer" value="87 Market Street" id="questions[1].answer_2"></input>
                                <label for="questions[1].answer_2">87 Market Street</label>
                                <input type="radio" name="questions[1].answer" value="None of these" id="questions[1].answer_3"></input>
                                <label for="questions[1].answer_3">None of these</label>
                                <div class="clear"></div>
                </div>
                <br/><br/><br/><br/>
                <input type="submit" class="ButtonFirst" value="Submit" id="submitVerifyButton">
            </form>

我猜您的布局/页面中没有包含jquery.validation.js文件。尝试包含js文件。如果您没有使用jquery.validation,那么应该将其用于客户端验证。查看以下链接以了解更多详细信息。

所以我测试了你的代码,我不得不说你的代码工作得很好。你只是犯了个小错误。查看您的HTML代码,您会发现如下内容:

<input type="radio" name="questions[1].answer" value="1 Grape Vine" id="questions[1].answer_0"></input> 

输入字段的名称为问题。回答问题[0]。回答。在javascript代码中,您根据需要使用
*街道*和*cars*
的名称声明了无线电组。所以它指向表单中未定义的字段。 Jquery不会用未定义的错误消息来烦扰用户,因此您的脚本似乎无法工作


如果您不相信我,请看。

您介意只发布pur HTML源代码吗?因此,您可以接触到更多需要帮助的用户。这对我们大家来说都很容易。分别更新了HTML和java脚本代码。名字是正确的。另外,我发现的另一个问题是,我在名称中使用了[],而对于jquery,“[]”是一个特殊字符。所以当我尝试执行errorElement=$(“#err#”+id)时,它给出了错误。所以为了克服这个问题,我使用document.getElementById
<input type="radio" name="questions[1].answer" value="1 Grape Vine" id="questions[1].answer_0"></input>