我无法验证上传字段。字段名称是一个数组。如何使用jquery验证它? 这是我的代码:
<script type="text/javascript">
$().ready(function() {
// validate signup form on keyup and submit
var validator = $("#signupform").submit(function() {
// update underlying textarea before submit validation
}).validate({
rules: {
name: "required",
photo_path: { required: true }
},
errorPlacement: function(label, element) {
label.insertAfter(element);
},
messages: {
name: "Please enter your name",
photo_path: "Upload your Image"
}
});
});
</script>
<?php
$count=1;
for($i=0; $i<4; $i++)
{
?>
<input type="hidden" name="galleryImage[]" id="galleryImage[]" value="<?=$i?>"/> </td>
</tr>
<tr>
<td align="left" valign="middle" bordercolor="1" class="signup">Upload Image <?=$count?>:</td>
<td align="left" valign="middle" bordercolor="1"><input type="file" name="photo_path[]" id="photo_path" class="inputcolor_text" />
<br />
<?php
$count++;
}
?>
答案 0 :(得分:0)
放手一搏......
var validator = $("#signupform").submit(function(e) {
if(!$('.inputcolor_text').val()){
e.preventDefault();
// $('#error').html('Cannot be empty.');
return false;
}
}).validate.....