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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -