-
7 Aug 2008 3:55 AM #1
TextField and MaskRe
TextField and MaskRe
Hello,
I would like to have an input mask for : PE123.456
The first letter has always to be the letter P and The second letter has always to be the letter E.
After I have 3 digits, a dot and 3 digits again.
Thanks for help
Medley
-
7 Aug 2008 4:20 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Use:
Code:/^PE[0-9]{3}\.[0-9]{3}$/
-
7 Aug 2008 4:33 AM #3
I tried it in my code.
But it is impossible to enter a value. Firefox 3 or I7. Same behaviour.
Code:items: [{ xtype:'textfield', fieldLabel: TOP.displayReportDetails.field.report.numeroPE, name: 'peNumber', width : 75, maskRe : /^PE[0-9]{3}\.[0-9]{3}$/ }]
-
7 Aug 2008 4:47 AM #4
maskRe restricts character input to the characters specified. e.g. maskRe: /[a-z]/ restricts character input to only lowercase alphabets.
won't work for your case.
p.s. seems like the only thing that will be accepted is a single regex character class.
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
7 Aug 2008 4:51 AM #5
And by using regex, how to have the same result ?
I don't know how works regex.
Medley
-
7 Aug 2008 4:52 AM #6
you can't. not with a normal TextField as far as i can see.
closest thing to filtering keystrokes you could do now is:
[edit]Code:// restrict character input to only 'P', 'E', digits and the decimal point maskRe: /[PE0-9.]/
hold on.. i think i just thought of something.. let me whip something upLast edited by mystix; 7 Aug 2008 at 4:58 AM. Reason: update
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
7 Aug 2008 4:56 AM #7
try this
Code:Ext.onReady(function() { Ext.QuickTips.init(); new Ext.form.TextField({ maskRe: /[PE0-9.]/, validator: function(v) { return /PE[0-9]{3}\.[0-9]{3}/.test(v)? true : 'Entered text must be of the form PExxx.xxx, where x represent digits 0-9.'; }, renderTo: document.body }); });Last edited by mystix; 7 Aug 2008 at 5:02 AM. Reason: updated to obey return values specified in docs
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
7 Aug 2008 4:57 AM #8Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Correct, you can't use that as a maskRe. Use the following vtype instead:
Code:var peNumberTest = /^PE[0-9]{3}\.[0-9]{3}$/; Ext.apply(Ext.form.VTypes, { peNumber: function(v) { return peNumberTest.test(v); }, peNumberText: 'Invalid PE number', peNumberMask: /[PE0-9.]/ }); ... items: [{ xtype: 'textfield', vtype: 'peNumber', ... }]
-
7 Aug 2008 5:19 AM #9
Is it possible to block the input to n characters ?
In my case, for example, I don't want to allow to enter more than 9 characters for the field peNumber.
-
7 Aug 2008 5:21 AM #10
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )


Reply With Quote