Skip to main content

How can I use the unbounce forms in such a way to show the State/Province field only if someone is from US or Canada?

A second feature would be to show only the relevant States for US and Province for Canada

Hey @aquamine! There isn’t a way to do this natively within the page builder. However, with some javascript, this could be possible. You could hide some elements based on IP addresses.


Our @Unbounce-Experts are more versed in javascript than I am (by leaps and bounds) so they may have more insight into this. But I might also see if folks from our tech team would be willing to provide some feedback here.


How comfortable are you with javascript? Let’s start there. ☺


Hey @aquamine, as Jess mentioned, this would involve some javascript.


I had a quick stab at it to help you out:


Here is a sample form in action

http://unbouncepages.com/test-form-143/


How to do this:




  • Create a form with the standard Unbounce “country” and “state/province” fields (located under the drop down form options in the form builder)




  • Add a “No State/Province” to the end of the state/province field options. The script will auto set the state/province to this when a country is not USA/Canada




  • Add this script to the Unbounce page, placed “Before Body End Tag”





Please note that this will simply hide/show the state field. When the field is hidden, there will be a blank space. If that is an issue, you can mess around with height/ positioning yourself to alter that.





Hope that helps!

Cheers

Brian


Woot! This is awesome @Brian_Hemeryck!! Thanks for chiming in here. 🙌 :spinbounce:


Hey @aquamine!

 

🚀 We have a brand new, complete solution for adding Country Codes and Flags to Unbounce!

🆓 FREE Version:


💎 PRO Powerful Version:
👉 https://www.grooic.com/cfu-unbounce

 

👀 Check Out the Live Preview Here:

🌐 https://www.grooic.com/cfu-preview/

 

🤝 If you have any questions or need support, feel free to reach out to us on WhatsApp: 💬 +1 917 900 3111

Thanks,


Reply