Hello,
I am using the code below to allow certain characters into username or other textboxs. The main goal is if user accidently touches spacebar, the code should prevent spacebar from adding any space. The code works fine on my laptop. However, this code doesn't work on smartphone. I checked it on my smartphone (Samsung) and it adds space when I click spacebar. Can you tell me what is missing from this code to prevent space when a user uses smartphones and touches spacebar?
function IsAlphaNumericUsername(e) {
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
var ret = ((keyCode == 13) || (keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode));
document.getElementById("errorUsername").style.display = ret ? "none" : "inline";
return ret;
}