简体   繁体   English

验证纬度和经度jquery

[英]validate latitude and longitude jquery

I have walk through much to find valid regex in javascript to validate latitude and longitude separatly.我已经在javascript中找到了有效的正则表达式来分别验证纬度和经度。

but in vain..但徒劳..

tried the following but not working..尝试了以下但不起作用..

    var latlngVal = /^-?([0-8]?[0-9]|90)\.[0-9]{1,6},-?((1?[0-7]?|[0-9]?)[0-9]|180)\.[0-9]{1,6}$/;
    if (!latlngVal.test(this.value)) {
       //logic
    }

can anybody tell me the easiest way to validate the latitude and longitude entered in the textbox.谁能告诉我验证在文本框中输入的纬度和经度的最简单方法。

Or is there any mvc annotation to validate latitude and longitude?或者是否有任何 mvc 注释来验证纬度和经度?

I made it with following..我用以下方法做到了..

$(".longitude").focusout(function () {
    debugger;
    var lngVal = /^-?((1?[0-7]?|[0-9]?)[0-9]|180)\.[0-9]{1,6}$/;
    if (!lngVal.test(this.value)) {
       //logic
    }
});

for latitude validation use用于纬度验证使用

var latVal = /^-?([0-8]?[0-9]|90)\\.[0-9]{1,6}$/;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery,用于验证纬度和经度正则表达式 - jQuery for validating latitude and longitude regex 用jQuery分隔谷歌地图的经度和纬度 - Separate Latitude and Longitude of googlemaps by jQuery 正则表达式验证纬度和经度的输入格式 - Regex Expression to validate input format of Latitude and Longitude 如何在javascript中分别验证纬度和经度? - How to validate latitude and longitude separately in javascript? 使用jQuery Mobile在“ pageshow”上捕获经度和纬度坐标 - Capturing longitude and latitude coordinates on 'pageshow' with jQuery Mobile Jquery Inputmask 纬度和经度验证和屏蔽? - Jquery Inputmask Latitude & Longitude Validation and Masking? 为什么使用正则表达式来验证 Javascript 中的纬度和经度? - Why use regular expressions to validate latitude and longitude in Javascript? 如何验证您在Google地图上指定的经度和纬度上到达的位置 - How to Validate Your Position Arrived on Tasked Latitude and Longitude on Google Maps 如何使用 php 和 jquery 在 google map 中动态添加经纬度? - How to add latitude and longitude in google map dynamically using php and jquery? Jquery - 如何按纬度和经度获取位置名称详细信息 - Jquery - How to get location name details by latitude and longitude
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM