Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  99] [ 1]  / answers: 1 / hits: 18920  / 10 Years ago, thu, march 20, 2014, 12:00:00

I just came across the accept attribute of <input type=file> and i really like it as i see that i don't need to write seperate validation for input file type if i use this attribute. its very simple like



<input type=file accept=image/*> will accept only image files..



<input type=file accept=audio/*> will accept only audio files..



<input type=file accept=video/*> will accept only video files..



However i see that if i some how select a different file then i see an error message



Please enter a value with a valid mimetype.



i just want to know if it i can somehow change this error message and print it so something of my choice.. also is it possible to add some css to this error message ??


More From » jquery

 Answers
6

Try using a little bit of JavaScript magic (mark the oninvalid attribute):



<input type=file accept=image/* oninvalid=setCustomValidity('Please, blah, blah, blah ')/>

[#71887] Wednesday, March 19, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
talonb

Total Points: 596
Total Questions: 103
Total Answers: 91

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
;