Home >Web Front-end >JS Tutorial >A small example of how to prevent spaces from being entered in a js control form_javascript skills

A small example of how to prevent spaces from being entered in a js control form_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:13:411214browse
复制代码 代码如下:

window.onload=function()
        {   
            var inputs=document.getElementsByTagName("input");
            for (var i=0;i                if(inputs[i].getAttribute("type")=="text")
                 inputs[i].onkeyup=function(){
                    this.value=this.value.replace(/(^/s )|/s $/g,"");
                 };
            } 
        } 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn