Mickey Cheong
Mickey Cheong

Reputation: 3010

File input javascript event, is there an event fire when someone click okay on the dialog box?

When someone click on Browse for the input file below:

<input type="file" name="blah" />

A dialog box will appear. The user will then select a file and click 'Ok'. The dialog box will close. Is there an event fire because of that? I tried onfocus and onblur, it didnt work out.

The only way I can think of is to start a timer to check the value content when it is onfocus. Not that elegant. Any solution?

Cheers, Mickey

Upvotes: 1

Views: 992

Answers (1)

Rajat
Rajat

Reputation: 34128

I think you can try to listen for an "onchange" event on your element.

The only drawback with this is if the user selects the same file using "browse" twice, it wont fire as the contents didnt change but I dont know if that is a requirement in your case.

Upvotes: 2

Related Questions