[英]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.