Check input type = file with onBlur

I can use onBlur to check input type = text or textarea, however I was not able to get the same to work for type = file.

It works:

<input type='text' name='sometextfield' size=30 class='input' onBlur="alert('Frell me dead, it works!');"

This is not (without errors):

  <input type='file' name='file_upload' size=30 class='input' onBlur="alert('Frell me dead, it works!');"> 

What is the trick for checking the correct input of type = file input fields on the fly? I would like to do it in vanilla Javascript. I am testing Chrome 17.0.963.56 and Firefox 10.0.2 under Ubuntu.

Thanks for the tips / pointers.

0
source share
1 answer

Try using onchange-event:

<input type="file" name="file_upload" size="30" class="input" onchange="alert('Frell me dead, it works!');">

Demo: http://jsfiddle.net/TimWolla/azvGP/

+4
source

All Articles