让页面所有的文本框不能输入空格(JavaScript)

        window.onload=function()
        
{
            
var inputs=document.getElementsByTagName("input");
            
for (var i=0;i<inputs.length; i++
                
if(inputs[i].getAttribute("type")=="text")
                 inputs[i].onkeyup
=function(){
                    
this.value=this.value.replace(/(^\s+)|\s+$/g,"");
                 }
;
            }
 
        }
posted @ 2007-08-24 09:31  农民伯伯  阅读(1798)  评论(2编辑  收藏  举报