使用onBlur验证输入类型=文件 [英] Validate input type=file with onBlur
本文介绍了使用onBlur验证输入类型=文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用onBlur来验证type = text或textarea输入,但是我无法为type = file工作。
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.
这有效:
<input type='text' name='sometextfield' size=30 class='input' onBlur="alert('Frell me dead, it works!');"
这不是(没有错误):
<input type='file' name='file_upload' size=30 class='input' onBlur="alert('Frell me dead, it works!');">
在运行中验证type = file输入框的技巧是什么?我想在vanilla Javascript中这样做。我正在使用Ubuntu下的Chrome 17.0.963.56和Firefox 10.0.2进行测试。
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.
感谢提示/指示。
推荐答案
尝试使用onchange-Event:
Try using the onchange-Event:
<input type="file" name="file_upload" size="30" class="input" onchange="alert('Frell me dead, it works!');">
演示: http://jsfiddle.net/TimWolla/azvGP/
这篇关于使用onBlur验证输入类型=文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文