|
1 | 1 | /** |
2 | | - * Gravity Perks // GP Address Autocomplete // Re-add Street Number to Address |
3 | | - * |
4 | | - * In some situations with Google Places Autocomplete, the street number may be dropped after autocompletion if Google |
5 | | - * does not think the address exists. Oftentimes, the address will show in the results, but the actual street number |
6 | | - * will be un-bold meaning it's not matching. |
7 | | - * |
8 | | - * After selecting the place, Places Autocomplete will briefly populate the input with the street number, but the actual |
9 | | - * `google.maps.places.PlaceResult` result will not contain it. |
10 | | - * |
11 | | - * This snippet will use the address that is briefly populated if it detects that the populated place does not contain |
12 | | - * a street number, but a street number was originally entered. |
13 | | - * |
14 | | - * https://gravitywiz.com/documentation/gravity-forms-address-autocomplete |
15 | | - * |
16 | | - * Instructions: |
17 | | - * 1. Install our free Custom JavaScript for Gravity Forms plugin. |
18 | | - * Download the plugin here: https://gravitywiz.com/gravity-forms-code-chest/ |
19 | | - * 2. Copy and paste the snippet into the editor of the Custom JavaScript for Gravity Forms plugin. |
| 2 | + * We're no longer using the experimental folder for experimental snippets. 🚧 |
| 3 | + * You can now find the snippet here: |
| 4 | + * https://github.com/gravitywiz/snippet-library/blob/master/gp-address-autocomplete/gpaa-use-street-number-if-not-returned-in-place.js |
20 | 5 | */ |
21 | | -window.gform.addFilter('gpaa_values', function( values, place, gpaa, formId, fieldId ) { |
22 | | - /* If the value coming back for Address 1 doesn't contain a street number, let's pull it from the input as Places Autocomplete will briefly populate the input. */ |
23 | | - if ( ! values.address1.match( /^(\d+)\s+.*/ ) && gpaa.inputs.address1.value.match( /^(\d+)\s+.*,/ ) ) { |
24 | | - var adrSplit = gpaa.inputs.address1.value.split(','); |
25 | | - |
26 | | - values.address1 = adrSplit[0]; |
27 | | - } |
28 | | - |
29 | | - return values; |
30 | | -}); |
0 commit comments