Aniket Narvankar

Aniket Narvankar

  • 531
  • 2.1k
  • 581.3k

Latitude Longitude Validation using Javascript in .net

Jul 1 2022 4:46 AM

I have two textbox one for latitude and other for longtitude.

following is the regex i am using 

for latitude /^(\+|-)?(?:90(?:(?:\.0{1,7})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,7})?))$/g

and for longitude /^(\+|-)?(?:180(?:(?:\.0{1,7})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,7})?))$/g

There is submit button,when user enter latitude and longitude and clicks submit button,we compare latitude and longitude base on regex,if it is invalida do not allow user to proceed further. but instead of button click i have to do it on textbox keypress,while entering he will not be allowed to enter latitude and longitude which does not matches the regex,please lete me know how this could be done on textbox keypress


Answers (3)