3

I have used ng-pattern

/^[0-9]{1,7}(\.[0-9]+)?$/

for validate latitude and longitude values, but this pattern is not allowing me to enter negative values.

Latitude and longitude values contains negative and decimal values Can you please suggest me one good ng-pattern for my requirements.

Example values are given below

234.546655, 3.5766876, 12345.766566

I need validation for this type values. It should allow negative,positive,decimal and all numbers

Max Leske
  • 5,007
  • 6
  • 42
  • 54
NIKHIL K A
  • 328
  • 5
  • 16
  • For longitude, you don't need a value larger than ±180, and latitude no larger than ±90. – RobG Jun 01 '16 at 06:49

1 Answers1

4

This is a complete answer: https://stackoverflow.com/a/18690202/6359058

For your example: [-+]? is required for either - or +

/^[-+]?[0-9]{1,7}(\.[0-9]+)?$/
Community
  • 1
  • 1
Colin Fiat
  • 74
  • 6
  • 1
    You should mark the question as a duplicate rather than answer with a link. – RobG Jun 01 '16 at 06:53
  • Thanks @ColinFiat it's working – NIKHIL K A Jun 01 '16 at 09:40
  • Thanks RobG. Can you tell me how to do that? I can't see a specific button or control. However, the question posed was how to get the sign's included in his current regular expression. I've answered above that simple request by adding a link to a more complete answer to a question he did not ask. – Colin Fiat Jun 01 '16 at 12:18