Question

I'm able to use onBlur to validate type=text or textarea inputs, however I haven't been able to get the same to work for type=file.

This works:

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

This does not (no error):

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

What is the trick to validating type=file input boxes, on the fly? I'd like to do this in vanilla Javascript. I'm testing with Chrome 17.0.963.56 and Firefox 10.0.2 under Ubuntu.

Thanks for tips/pointers.

Was it helpful?

Solution

Try using the 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/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top