jquery禁止回车触发表单提交

时间:2014-12-12    点击:98   

复制代码 代码如下:

<form class="form-inline definewidth m20" action="/" method="get"> 
            <input type="text" name="title" id="title"class="abc" value="">   
            <button type="submit" class="btn" style="margin-right:20px">查询</button>
            <select name="school_type" id="school_type">
</form>
<td style="width:90px; height:24px; text-align:center"><input   type="text" name="test" value="" class="a"></td>

test文本框的回车事件会触发上面表单的提交,这是浏览器的默认行为,要禁止自动提交,在文本框里取消默认事件。

复制代码 代码如下:

$('.a').keypress(function(e){
            if(e.keyCode==13){
                e.preventDefault();
            }

测试过IE10 FF29正常

让javascript加载速度倍增的方法(解决JS加载速度慢的问题)
jQuery实现瀑布流布局
jquery+ajax验证不通过也提交表单问题处理
js 左右悬浮对联广告代码示例
原生JavaScript+LESS实现瀑布流
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved