Gravity Forms JavaScript Helpers
jQuery(function($) { $(‘.gform_wrapper FORM’).on(‘change’, ‘.post-code INPUT’, function(evt) { evt.stopImmediatePropagation(); const field = $(this), postCode = field.val(); $.get({ url: `https://apis.postcode-jp.com/api/v6/postcodes/${postCode}?apiKey=BJ7qtSrq0iYgWj9AV0P4esvTTX1gmq48813DoE1&normalize=true&fields=allAddress,prefCode,city,town` }).always(function(response) { console.log(‘RESPONSE:’, response); if(!Array.isArray(response)) return; const form = field.closest(‘FORM’), result = response[0]; if(result.prefCode) $(‘.prefecture SELECT’, form).val(result.prefCode); if(result.city) $(‘.street INPUT’, form).val(`${result.city}${result.town}`);…Continue reading