how to allow space?
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
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) && ...
精彩评论