$('#form-address').validate({
  ignore: ":hidden:not(.ftr-js-select__value)",
  onkeyup: function(element) {
    if ($(element).valid()) {
      $(element)
        .closest('div[class|=ftr], label[class|=ftr]')
        .removeClass('error');
      $(element)
        .siblings('.ftr-field__error')
        .remove();
    }
  },
  onsubmit: true,
  showErrors: function(errorMap, errorList) {
    $.each(errorList, function() {
      $($(this)[0].element)
        .closest('div[class^=ftr], label[class^=ftr], div[class*=ftr], label[class*=ftr]')
        .addClass('error')
        .find('.ftr-field__error')
        .remove();
      $($(this)[0].element)
        .closest('div[class^=ftr], label[class^=ftr], div[class*=ftr], label[class*=ftr]')
        .append(
          $('<span>')
            .addClass('ftr-field__error')
            .text($(this)[0].message)
        );
    });
  },
  rules: {
    postcode: {
      postalcodeBR: true,
    },
  },
});
