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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -