let value_error = false; // Flag if Lat/Lon values are out of range. let latitude_low = 38.0; let latitude_high = 40.0; let longitude_low = -96.0; let longitude_high = -94.0; function submitForm() { // Clear values value_error = false; $("#latitude_error").html(''); $("#longitude_error").html(''); // Set Vars let nLatitude = $("#latitude").val(); let nLongitude = $("#longitude").val(); if ((!$.isNumeric(nLatitude)) || (!inRange(nLatitude,latitude_low,latitude_high))) { $("#latitude_error").html('Please enter a value between ' + latitude_low + ' and ' + latitude_high); value_error = true; } if ((!$.isNumeric(nLongitude)) || (!inRange(nLongitude,longitude_low,longitude_high))) { $("#longitude_error").html('Please enter a value between ' + longitude_low + ' and ' + longitude_high); value_error = true; } // if Lat or Lon values are out of range return to form. if (value_error) { return; } alert('Submit Form'); }