Pergunta

Consigo usar onBlur para validar entradas type=text ou textarea, mas não consegui fazer o mesmo funcionar para type=file.

Isso funciona:

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

Isso não acontece (sem erro):

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

Qual é o truque para validar caixas de entrada type=file em tempo real?Eu gostaria de fazer isso em Javascript vanilla.Estou testando com Chrome 17.0.963.56 e Firefox 10.0.2 no Ubuntu.

Obrigado por dicas/indicações.

Foi útil?

Solução

Tente usar o evento onchange:

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

Demonstração: http://jsfiddle.net/TimWolla/azvGP/

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top