PDA

View Full Version : exclude special characters from textfield



rjanos
13 Feb 2008, 3:31 PM
Hello,

I am trying to create an editable comboBox which accepts only certain characters.
I tried to set maskRe as

maskRe: new RegExp("^[a-zA-Z1-9_ ]*$")

However in IE the special characters get through (#,$,etc). If I saw it right it is because the filterKeys method has this exit branch:
if(Ext.isIE && (e.isSpecialKey() || !cc)){
return;
}

before the maskRe validation.

Can somebody tell me how can I force the textfield to allow only these characters:
a-zA-Z1-9_ and space ?

thanks,
Janos

RWaters
23 Feb 2008, 7:56 AM
Try a '+' instead of a '*' at the end. * will match if it is present or if it is not.

zig999
4 Mar 2008, 10:53 AM
Take a look here (http://extjs.com/forum/showthread.php?p=133187#post133187). I was running into the samen problem.