我有一个奇怪的问题。我有一个文件上传和几乎没有其他textarea的表单。每个字段都是必需的。所以基本上当几个字段留空时,验证工作正常,但当且仅当文件上传空白时,表单才会被提交。使用jQuery验证插件进行文件上传验证
这里是我的代码
<li >
<p>
<label for="rad">radio label:
</label><br>
<input type="radio" name="rad" value="yes" style="width:20px"> Yes </input>
<input type="radio" name="rad" value="no" style="width:20px"> No</input><br/>
<label for="cv" class="error" style="display:none">This field is required</label>
</p>
<p>
<input type="file" name="fupl" style="display:none;margin-top:10px" id="fup"/>
<label for="fupl" class="error" style="display:none;color:red">This field is required</label>
</p>
</li>
<br>
<li>
<label>checkbox label
</label><br><br>
<input type="checkbox" name="cb" value="tick" style="width:20px"> <small>checkbox field<small></input><br> <label for="fee" class="error" style="display:none">This field is required</label>
</li>
<br><li>
<input type="submit" class="button" value="SUBMIT" style="float:right"/>
</li>
<script>
$(document).ready(function()
{
$("input[type='radio']").change(function(){
if($(this).val()=="yes")
{
$("#fup").show();
}
else
{
$("#fup").hide();
}
});
});
,这我的jQuery
$('#form').validate({
rules: {
fupl: {
required: true,
accept:'docx|doc'
},
你在你的代码显示上面没有'form'标签。 – Sparky 2013-02-28 23:51:36