2

how i can have a field (lightning:input) in which i can write 3 integer and 3 decimal? Something like 123.456 (max 3 integer and max 3 decimal, with "." or "," between integer and decimal). I try to use the attribute pattern, but i don't have good results. Thanks for help in advice

5
  • When you say 3 integers and 3 decimals, do you mean one number formatted like this? Commented Jun 12, 2017 at 8:44
  • yes, a number formatted like 123.456 or 12.345 or 12,3 etc...
    – user45926
    Commented Jun 12, 2017 at 8:55
  • 1
    You should probably use the ui:inputNumber instead of the lightning:input. And specify a format on the specific attribute. Commented Jun 12, 2017 at 9:39
  • i was order to use lightnint:input :/
    – user45926
    Commented Jun 12, 2017 at 11:05
  • I would not use ui:inputNumber as it has been deprecated by Salesforce.
    – nbrown
    Commented Apr 23, 2020 at 14:53

1 Answer 1

-1

Try this pattern,

^([1-9]{0,1})([1-9]{0,1})([0-9]{1})((\.[0-9]{0,1})([0-9]{1})|(\,[0-9]{0,1})([0-9]{1}))(([0-9]{1}))?$
1
  • 3
    This pattern doesn't work for numbers like "100". How about ^\d{1,3}(?:(\.|\,)\d{1,3})?$? It's much less verbose.
    – nbrown
    Commented Apr 23, 2020 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .