PDA

View Full Version : Numberfield with maskRe accepting '.' and '-' problem



saga56
29 Aug 2011, 2:12 AM
in extjs 3 i´ve used maskRe: /^[0-9]$/ to accept only numbers between 0-9, but on
extjs 4 the '.' and '-' are now accepted too, how do i solve this only accepting
0-9 numbers on a NumberField?

droessner
29 Aug 2011, 4:45 AM
Is this just a regular expression question? Are you looking for a regular expression for allowing 0-9, '.', and '-'? In that case it should be /[0-9\.\-]$/

saga56
29 Aug 2011, 4:53 AM
Only 0-9, but the chars '.' and '-' keep appearing

carol.ext
29 Aug 2011, 12:23 PM
Did you try using minValue & allowDecimals on your Ext.form.field.Number aka xtype='numberfield'? Sounds like you are working against the number field by using the mask it inherits from textfield.

Careful with trailing commas if you paste this :


minValue: 0,
allowDecimals: false,

saga56
30 Aug 2011, 12:29 AM
Did you try using minValue & allowDecimals on your Ext.form.field.Number aka xtype='numberfield'? Sounds like you are working against the number field by using the mask it inherits from textfield.

Careful with trailing commas if you paste this :
This solve my problem. I didn't know that allowDecimals existed :/. Thank you very much!!!