sgruhier/typeahead-addresspicker

How can I prevent or advise an user from submit an address that doesn't exist?

Closed this issue · 2 comments

If user type a wrong address the console show this error:

 Uncaught TypeError: Cannot read property 'length' of null

the reason is that predictions is null.
line 148

 for (_i = 0, _len = predictions.length; _i < _len; _i++) {

it would be nice to capture this mistake so that I can advise the user.
I would like to prevent user from submit an address that doesn’t exist

I added a new event addresspicker:predictions and updated the first address pricker example with that code.

    $(addressPicker).on('addresspicker:predictions', function(event, result) {
      if (result && result.length > 0)
        $('#address1').removeClass("empty")
      else
        $('#address1').addClass("empty")
    })

thank you very much 👍 :)