javascript - Validate at least 1 file input is completed with jQuery -
javascript - Validate at least 1 file input is completed with jQuery -
here form
<form action="b.php"> <input type="file" name="file[]"> <input type="file" name="file[]"> <input type="file" name="file[]"> <input type="file" name="file[]"> <input type="submit" value="value"> </form>
the questions how ensure @ to the lowest degree 1 field have selected file jquery?
try this:
var validfields = $('input[type="file"]').map(function() { if ($(this).val() != "") homecoming $(this); }).get(); if (validfields.length) { alert("form valid"); } else { alert("form not valid"); }
example fiddle
javascript jquery html
Comments
Post a Comment