Skip to content

Commit d7d8d05

Browse files
committed
#44 check input fields
1 parent de0c1fb commit d7d8d05

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/locationpicker.jquery.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@
188188
if (inputBinding) {
189189
if (inputBinding.radiusInput){
190190
inputBinding.radiusInput.on("change", function(e) {
191-
if (!e.originalEvent) { return }
192-
gmapContext.radius = $(this).val();
191+
var radiusInputValue = $(this).val();
192+
if (!e.originalEvent || isNaN(radiusInputValue)) { return }
193+
gmapContext.radius = radiusInputValue;
193194
GmUtility.setPosition(gmapContext, gmapContext.location, function(context){
194195
context.settings.onchanged.apply(gmapContext.domContainer,
195196
[GmUtility.locationFromLatLng(context.location), context.radius, false]);
@@ -239,18 +240,19 @@
239240
}
240241
if (inputBinding.latitudeInput) {
241242
inputBinding.latitudeInput.on("change", function(e) {
242-
if (!e.originalEvent) { return }
243-
GmUtility.setPosition(gmapContext, new google.maps.LatLng($(this).val(), gmapContext.location.lng()), function(context){
244-
context.settings.onchanged.apply(gmapContext.domContainer,
243+
var latitudeInputValue = $(this).val();
244+
if (!e.originalEvent || isNaN(latitudeInputValue) ) { return }
245+
GmUtility.setPosition(gmapContext, new google.maps.LatLng(latitudeInputValue, gmapContext.location.lng()), function(context){ context.settings.onchanged.apply(gmapContext.domContainer,
245246
[GmUtility.locationFromLatLng(context.location), context.radius, false]);
246247
updateInputValues(gmapContext.settings.inputBinding, gmapContext);
247248
});
248249
});
249250
}
250251
if (inputBinding.longitudeInput) {
251252
inputBinding.longitudeInput.on("change", function(e) {
252-
if (!e.originalEvent) { return }
253-
GmUtility.setPosition(gmapContext, new google.maps.LatLng(gmapContext.location.lat(), $(this).val()), function(context){
253+
var longitudeInputValue = $(this).val();
254+
if (!e.originalEvent || isNaN(longitudeInputValue) ) { return }
255+
GmUtility.setPosition(gmapContext, new google.maps.LatLng(gmapContext.location.lat(), longitudeInputValue), function(context){
254256
context.settings.onchanged.apply(gmapContext.domContainer,
255257
[GmUtility.locationFromLatLng(context.location), context.radius, false]);
256258
updateInputValues(gmapContext.settings.inputBinding, gmapContext);

0 commit comments

Comments
 (0)