How to restrict ExtJs Textfield to accept only numbers using maskRe . (Should accept Positive , Negative , integer and decimal numbers.)
问题 I need to configure my ExtJs textfield to accept only numbers which can be positive , negative , integer and decimals upto 2 decimals . I tried with maskeRe and regular expression /^-?[0-9]\d*(\.\d+)?$/ . But its accepting only positive integers. User should not be able to type restricted characters. Also it should accept '-' only at first place and '.' in between and only once. So it should accept : 10, -10, 10.12, -10.34 etc Link to my fiddle Thanks 回答1: Change your maskRe to maskRe: /[0-9.