Limiting input to specified regexp with uppercase chars in IE
- by pixelboy
I'm trying to limit what our users will be able to type in inputs, using javascript/jquery.
Problem is, I have to limit this to Uppercase chars only, and numbers.
Here's what I coded previously :
$(input).keydown(function(e){
if ($(input).attr("class")=="populationReference"){
var ValidPattern = /^[A-Z_0-9]*$/;
var char = String.fromCharCode(e.charCode);
if (!ValidPattern.test(char) && e.charCode!=0){
return false;
e.preventDefault();
}
}
});
If Firefox supports charCode, IE doesn't. How then, could I test if the user is typing uppercase or lowercase characters ?
Thanks for any help !