I tried to use a form validation hook to validate zip code (5 digit) on my form. But somehow it's not working.
Here's the code that I enter in my theme functions file.
Please advise
I tried to use a form validation hook to validate zip code (5 digit) on my form. But somehow it's not working.
Here's the code that I enter in my theme functions file.
Please advise
Are you using the zip code field that is part of the address field? Or a separate field?
If you are using a separate field, you might consider using a single line text field and set the character limit to 5: http://grab.by/agfI
I am using the number field and I need the entry to be numbers and 5 digits in length.
Actually I tried to used the option where I can specify that the entry must be beween 0 to 99999 but I need it to be 5 digits.
The code seems to "work" since I get the error message but it gives me that error even when I enter a 5 digit number.
Yep, that worked for me no problem: http://grab.by/aggc
Ditch the custom code and let me know what error message you are receiving.
by Using the second method, I don't have an error message. However a zip code must be 5 digits. if someone enter a 3 digit number (ie.. 654 or 8756). the form will be process the wrong info.
I want to make sure that a 5 digit number is enter (ie 07612).
Are you dealing with any zipcodes that start with zero? If not, try upping the range from 0 - 99999 to 10000 - 99999.
Yes I do, That's why I was looking at custom validation once I realized that a lot of east coast zipcodes start with 0.
So I need something that verify that the entry is 5 digits.
Hi Muhacus,
Thanks for bearing with me as we came back to square one. :)
Try add a "return true" to your validate function like so:
Hi David,
I'm having the same problem, I'm using the number field with min/max 0-99999 but need to have it accept only 5-digit entries. Where would I add that validate function?
Hi Redkite,
Here is the completed functional script: http://pastie.org/2015527
You would paste this in your theme's functions.php file.
Is it possible to remove the 'Please enter a value between 00000 and 99999.' text below the zip code number field?
Hi redkite, each field has a custom validation message setting in the GF form admin. You can set that message to whatever you'd like.
Found it, thank you!