禁止回发 js

来源:互联网 发布:查linux系统版本 编辑:程序博客网 时间:2024/06/06 05:29

1.第一种

 window.event.returnValue = false;
//          return false;

2.第二种

             e.preventDefault();
                    return false;

3. js 正则表达式

   $("#btnSels").click(function(e) {
                parm = /^[0-9]{0,20}$/;
                if (!parm.exec($("#txtWEIGHT0").val())) {
                    alert("重量請輸入數字!");

                    e.preventDefault();
                    return false;
                }
            });



 

 4.选中

            $("#txtZipCode2").focus(function() {
                this.select();
            })

原创粉丝点击