I'm trying to create a regular expression for matching latitude/longitude coordinates that fall within the correct range. But the below code is giving error. Please let me know where I am going wrong:
Angular:
var app = angular.module('myapp', []);
app.controller('latlong', function($scope) {
$scope.name = "Valiadtion";
$scope.lat = "latitude";
$scope.long = "longitude";
$scope.submit = function() {
var lat = $scope.lati;
var reg = /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/;
if (reg != lat) {
console.log('error');
}
}
});
Here is the Plunker