【发布时间】:2015-10-12 17:13:26
【问题描述】:
我有包含 4 个文件类型输入字段的图像上传加载器页面,现在我想要那个,用户应该在选择所有 4 个图像而不是少于 4 个图像文件后提交表单。即在我的页面中,用户可以在选择 1 个文件后提交,但我只是在选择所有文件后提交表单。请帮帮我。
$('#upimg').submit(function() {
$(".imgp").each(function() {
var imgnm = $(this).val();
if (imgnm === '') {
$("#dialog").html("<p><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>Please select Image to upload.</p>");
$("#dialog").dialog("open");
return prevantDefault();
}
});
});
<table>
<tbody>
<tr>
<td><strong style="color: red; font-size: larger;">*</strong>
<input type="file" accept="image/*" name="imgfile[]" id="imgfile" class="imgp">
</td>
<td>
<input placeholder='image name' type="text" size="20" class="inm ui-corner-all ui-widget input" id="imgname" name="imgname[]">
</td>
</tr>
<tr>
<td><strong style="color: red; font-size: larger;">*</strong>
<input type="file" accept="image/*" name="imgfile[]" id="imgfile" class="imgp">
</td>
<td>
<input placeholder='image name' type="text" size="20" class="inm ui-corner-all ui-widget input" id="imgname" name="imgname[]">
</td>
</tr>
<tr>
<td><strong style="color: red; font-size: larger;">*</strong>
<input type="file" accept="image/*" name="imgfile[]" id="imgfile" class="imgp">
</td>
<td>
<inputp placeholder='image name' type="text" size="20" class="inm ui-corner-all ui-widget input" id="imgname" name="imgname[]">
</td>
</tr>
<tr>
<td><strong style="color: red; font-size: larger;">*</strong>
<input type="file" accept="image/*" name="imgfile[]" id="imgfile" class="imgp">
</td>
<td>
<input placeholder='image name' type="text" size="20" class="inm ui-corner-all ui-widget input" id="imgname" name="imgname[]">
</td>
</tr>
</tbody>
<tr align="center">
<td colspan="4">
<input type="submit" value="Submit" id="button" class="ui-state-default ui-corner-all ui-button-text">
<input type="reset" value="Reset" class="ui-state-default ui-corner-all ui-button-text">
</td>
</tr>
</tfoot>
</table>
我使用了四个输入文件,因为用户可以单独更改图像文件名。 如何设置用户必须在所有 4 张图片选择后提交表单。
【问题讨论】:
-
你能创建一个你的代码的小提琴吗?
-
我是全新的我无法理解@DinoMyte
-
转到jsfiddle.net 并将您的代码粘贴到那里。
标签: jquery