Reputation: 127
Iam working with ext js.I have a textfield that should accept either an integer or a decimal number. Iam using regular expression to implement that. But its not working.
Here is my code...
{
xtype: 'textfield',
id: 'myField',
fieldLabel: 'Text Field(numbers-only)',
maskRe: /[0-9]+(\.[0-9]+)?$/
}
While using the above regular expression, Textfield is not accepting .(dot)
How can I resolve this??
Upvotes: 4
Views: 12576
Reputation: 3424
Use Below code:
{
xtype: 'textfield',
id: 'myField',
fieldLabel: 'Text Field(numbers-only)',
maskRe: /^[1-9]\d*(\.\d+)?$/
}
Per your Understanding purpose see this link Click Here
Upvotes: 2
Reputation: 91385
Not sure I well understand your need, but is this OK?
/^[0-9]+(\.[0-9]*)?$/
This will accept:
123
0.123
123.
Upvotes: 1
Reputation: 2755
you can use this if you want to limit the number of decimal places:
^\d+(\.\d{1,2})?$
this will let you pass decimal places at least 1 but not more than 2
Upvotes: 1