开发者

how to allow space?

the below javascript code prevent user to put all special character including "space".

  1. through same function, I need to allow "space"..how to do this..please help
  2. however user is unable to type any special character, but user can copy/paste special character. Is there any way to prevent this also...one way disable right click on page..any other way..please suggest!

    function isValidSearchText(evt) {
        var charCode = (evt.which) ? evt.wh开发者_JS百科ich : event.keyCode;
        if ((charCode < 48 || charCode > 57) && (charCode < 97 || charCode > 122) && (charCode < 65 || charCode > 90))
            return false;
        return true;
    }
    


Change the if-statement from this

if ((charCode < 48 || charCode > 57) && ....

To this:

if (charCode != 32 && (charCode < 48 || charCode > 57) && ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜