Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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
表单的jQuery验证规则有问题_Jquery_Html_Forms_Validation - Fatal编程技术网

表单的jQuery验证规则有问题

表单的jQuery验证规则有问题,jquery,html,forms,validation,Jquery,Html,Forms,Validation,您好,我正在尝试使用jQuery验证 基本上我有一个表单,在这里,不管发生什么,都需要某些元素 但我还有其他字段,只有选中复选框时才需要 我正在使用jQuery验证 这里有一个链接 这是我的表格 <form action="http://www.funnytennisstories.com/save-story.php" method="POST" name="story-form" id="storyForm"> <fieldset> <label for

您好,我正在尝试使用jQuery验证

基本上我有一个表单,在这里,不管发生什么,都需要某些元素

但我还有其他字段,只有选中复选框时才需要

我正在使用jQuery验证 这里有一个链接

这是我的表格

<form action="http://www.funnytennisstories.com/save-story.php" method="POST" name="story-form" id="storyForm">
<fieldset>
    <label for="Your Story">Your Story</label>
    <textarea class="required" name="your-story" cols="" rows=""></textarea>
    <label for="free-wrist-band">Check the box to receive a free tennis wristband &nbsp;  </label>
    <input id="free-wrist-band-check-box" name="free-wrist-band" type="checkbox" />
    <label for="address">Address</label><input id="address" class="txtClass shipping" name="address" type="text" >
    <input type="submit" name="story-post" value="Post Your Story"/>
 </fieldset>
</form>

chrome上的firebug lite(和inspect元素工具)和safari上的inspector中也没有显示调试

任何想法都可以添加到
$(document.ready(function(){…})

因此,只有选中了
复选框
,才需要
地址文本框


您使用什么表单验证jQuery扩展?(谷歌给了我很多“jQuery验证”的结果。)或者你想写你自己的验证工具吗?编辑了这篇文章,靠近顶部
<script>

 $(document).ready(function(){

    $("#storyForm").validate({
    debug:true,
       rules: {
         shipping: {
             required: $("#free-wrist-band-check-box:checked")
           }
       }
    });
});
$('#free-wrist-band-check-box').on('change', function(){
    if($(this).is(':checked')) $("#address").rules("add", "required");
    else $("#address").rules("remove", "required");
});