如图,如果三个input都没有填,点击提交会出现三个提示,并且第一个input获得焦点,然后填完第一个,提交,后面两个input会提示不能为空,第二个input获得焦点,然后把第二个input填完,再点击提交,这时候,bug出来了,页面死了!!!!卡死了,完全动不了,第二个input后面的标签不消失,第三个input也不获得焦点,这个问题怎么解决啊,或者有没有更好的解决办法,适用所有的浏览器(主流的),
现在用的是谷歌内核的浏览器有问题,但是用ie暂时没有发现问题,运行完好。要兼容谷歌ie火狐safari等主流浏览器(主要兼容谷歌内核的),求大神帮忙看下,小弟不甚感激,先谢过了我的html代买如下
<table>
<tr>
<td>
<input type="text" class="notnull" />
<span style="display: none;"><b style="color: red;">*</b>日期不能为空</span>
</td>
</tr>
<tr>
<td>
<input type="text" class="notnull" />
<span style="display: none;"><b style="color: red;">*</b>时间不能为空</span>
</td>
</tr>
<tr>
<td>
<input type="text" class="Wdate notnull" onfocus="WdatePicker()" />
<span style="display: none;"><b style="color: red;">*</b>最后不能为空</span>
</td>
</tr>
</table>
<button id="aa">提交</button>
@Scripts.Render( "~/Scripts/My97DatePicker/WdatePicker.js" )
@Scripts.Render( "~/Scripts/Home/Home.js" )
写的是mvc架构,后面的是引用js,也可以直接加标签<script>引用js,下面是我写的js,
$(function () {
$('#aa').click(function () {
Valid();
});
});
function Valid() {
var IsFocus = false;
$('.notnull').each(function () {
var $_this = $(this);
var _value = $_this.val().replace(/\s/g, "");
if (_value == "") {
$_this.next().css("display", "");
if (!IsFocus) {
$_this.focus();
IsFocus = true;
}
}
else {
$(this).next().css("display", "none");
}
});
}
解决方案 »
- 关于qq2012带来的改变
- dreamweaver中可不可以仅用JavaScript操纵数据库
- 如何在 页面生成前运行JS脚本
- 我对google book的改写
- 高手请进,iframe搜索问题,困扰好久了
- 2月18号结婚,散分!(为保证技术帖,附加一段代码)
- nodejs,node-apn推送通知时513错误是什么?
- 在HTML页里有什么方法可以让<select>控制支持拷贝,谢谢!在线……
- 请问要如何在客户端判断一个文件的大小.
- 页面的打印问题
- easyui datagrid 中已经可以将数据全部显示出来,现在要在页面中根据比如姓名查询,在不用重新加载数据库的前提下,怎么在datagrid中实现
- easyui Cannot read property 'panel' of undefined
if (!IsFocus) {
setTimeout(function(){ $_this.focus();},100)
IsFocus = true;
}Web开发学习资料推荐