admin管理员组文章数量:1387346
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.
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.
Share Improve this question edited Mar 7, 2012 at 18:58 a coder asked Mar 7, 2012 at 18:52 a codera coder 7,66921 gold badges86 silver badges137 bronze badges 01 Answer
Reset to default 5Try using the onchange-Event:
<input type="file" name="file_upload" size="30" class="input" onchange="alert('Frell me dead, it works!');">
Demo: http://jsfiddle/TimWolla/azvGP/
本文标签: javascriptValidate input typefile with onBlurStack Overflow
版权声明:本文标题:javascript - Validate input type=file with onBlur - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744525227a2610704.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论