PDA

View Full Version : TextField maskRe not working



hat27533
5 Nov 2009, 8:14 AM
I have the following maskRe in a TextField and it does not seem to be working, is there a bug in the lib?

new Ext.form.TextField({
width:210,
enableKeyEvents:true,
maskRe: /^[\w ]+$/
});

The textField is within a toolbar in a GridPanel.


I am trying to prevent none Alpha numerics from being entered especialy '%' and '*'.

Any work around?

ValterBorges
5 Nov 2009, 8:37 AM
hat,
Here is how i do mine, i found that i've had to combine both maskRe and stripCharsRe to get the full desired effect. Note that stripCharsRe is a negation of maskRe.

Basically saying here is the allowed characters and then strip anything that's not it the allowed characters.



maskRe: new RegExp(/^[\d\.\,\$\-]$/)
,stripCharsRe: new RegExp(/^[^\d\.\,\$\-]$/)

ValterBorges
5 Nov 2009, 8:52 AM
You may also want to take a look at this thread.

http://www.extjs.com/forum/showthread.php?t=78495

hat27533
5 Nov 2009, 9:06 AM
I tried the stripCharsRe solution and can beat the browser (Chrome 3).

Thanks for the pointers I will keep trying...