开发者

how to allow space?

开发者 https://www.devze.com 2023-03-06 02:33 出处:网络
the below javascript code prevent user to put all special character including \"space\". through same function, I need to allow \"space\"..how to do this..please help

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

精彩评论

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