I’m trying to add validation to the zip code field on a custom form I built. My goal is to stop people from having to type in zip code, city, and state. Basically, if you enter the zip code, as soon as you enter the last (5th) digit, the city and state fields will automatically populate. In the examples I’ve found online for Java Script code I noticed you need to use an API like the google API.
I’ve been trying to accomplish this by adding javascript to wix code but no luck. Below is a link to an example of what I want done.
This is doable but instead of getJSON you will have to use fetch in wix. Maybe I should record a movie the sam ebut with WIX Code. Would you like that?
Thanks so much for posting the video and article. I saw the video and it makes sense but for some reason this is still not working for me.
I feel like I’m close but I think I’m still missing something. The code looks exactly the same and I made sure the input names matched. I’m no longer getting errors in the developer console when I preview because I added a data.js folder under backend. Now I get this:
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools. Loading the code for the Fill Out Personal Loan Form page. To debug this code, open hq59t.js in Developer Tools.
I added a masterPage.js and hq59t.js in the backend but I don’t think this does anything. I went to the browser developer tools and I did find some errors but I have no idea how to fix them. Everything in the Wix UI looks the same as what you showed on your video.
Not sure what I am missing. I will continue to try and see if I can figure it out. If I do I will post it here. Let me know if you have any other suggestions.
dont add any js files at all. your code should be in the page, not in some folder. click under the page for page code. screenshot to me where your code is located.
The code is on the page. I didn’t have any js files at first. I added them because I noticed that the developer console said “to debug this code, open masterPage.js in Developer Tools” Here is the screenshot.
You shouldnt, the code here should be in the Page Code, no backend files needed and you canät add a file called masterpage.js to your site. That is the Wix Code rendering engine that uses that page for debugging.
Hi - I have the same problem as previously discussed. I also tried the getJSON code and couldn’t get it to work. I’m extremely new to using both wixocde and javascript and would love to see any videos using the fetch command. Might you republish your video?
Hi Andreas. My code is exactly as outlined in your video with no errors on the coding page. When I test, I get the message “Failed to fetch”. I double-checked the validity of the API call using SOAPUI. Everything seems to be ok - am I missing something? Please see the screenshots. Thanks.
Hey
If your site is under HTTPS you can’t do a HTTP fetch, that will be treated now as a security breach in the browser because your code is executed in the browser. So you will have to move the code to a backend module to be able to it now.
I’m not sure I know how to do that. Are you basically saying I need to call the info from a database collection (I have one that has all of the zip codes, cities, states)?
Hi Andreas can you please share the video and sample as it is not available i want post code finder in my wix website in custom form.
Looking for kind response.
Best Regards
Azmat
Hi due to covid situation I want to give delivery service in a selected area,But there is no option found in wix website to add serviceable zip code/area