繁体   English   中英

使用onBlur验证输入类型=文件

[英]Validate input type=file with onBlur

我可以使用onBlur来验证type = text或textarea输入,但是我无法为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输入框的诀窍是什么? 我想用香草Javascript来做。 我正在Ubuntu下使用Chrome 17.0.963.56和Firefox 10.0.2进行测试。

感谢您的提示/指针。

尝试使用onchange-Event:

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

演示: http : //jsfiddle.net/TimWolla/azvGP/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM