自动去除输入框左右空格

来源:互联网 发布:阀门保温计算软件 编辑:程序博客网 时间:2024/05/20 08:26

function trim(str){ //删除左右两端的空格

        returnstr.replace(/(^\s*)|(\s*$)/g, "");

}           

$(document).ready(function(){//失去焦点时执行去除空格方法

        $("input[@type=text]").blur(function(){

               this.value= trim(this.value);

        });

        doQuery();

});

0 0