jquery - How do I make a file field required using javascript? -
i'm trying make form attachment field(file). want validate field. know how php, i'd rather use javascript it. know way this? searched around internet couldn't find solution..
this file field:
<input type="file" name="image" id="image" accept="image/*" />
you can try with:
<input type="file" name="image" id="image" accept="image/*" required />
and check js:
if ( $('#image').is(':empty') ) { // empty }
Comments
Post a Comment