my question is simple:
I have an input file field, and i want to limit it to only accept .GIFs via Jquery , and if the format is wrong, set the input value blank.
The problem is that on IE9, the .val('')
does not work. Any ideas?
My jQuery:
$('input[type=file]').change(function() {
var val = $(this).val();
switch (val.substring(val.lastIndexOf('.') + 1).toLowerCase()) {
case 'gif':
break;
default:
// error message here
alert("Wrong Format");
$(this).val('');
break;
}
});
From IE8 it is readonly try:
Picked from here : SO Anwser