Looking for gravity forms custom code

phukit

Well-known member
Trusted Uploader
Sep 30, 2018
190
320
63
Hi

Can anyone here help?

I am using gravity forms and using the predefined address fields/section.

there is no input mask for the zip/postal code and I am looking if someone can provide a snippet to achieve this.

Thanks!
 

phukit

Well-known member
Trusted Uploader
Sep 30, 2018
190
320
63
After talking to the gravity forms team, it is not possible to add an input mask to the address fields.

This only applies to a single text field, that's why the code wasn't working.
 

phukit

Well-known member
Trusted Uploader
Sep 30, 2018
190
320
63
I have finally developed a solution for input masking any form or input not just gravity forms.

Here is the solution if anyone is interested:

Code:
jQuery(document).ready(function(){

  jQuery('#INPUT_ID_GOES_HERE').mask('MASK_GOES_HERE');

});
 
Last edited:
  • Like
Reactions: 666

frizzel

Well-known member
Trusted Uploader
Jun 13, 2019
485
253
63
Wherever my imagination takes me
I have finally developed a solution for input masking any form or input not just gravity forms.

Here is the solution if anyone is interested:

Code:
jQuery(document).ready(function(){

  jQuery('#FORM_ID_GOES_HERE').mask('a9a - 9a9');

});
It's indeed in the description of how to use the jQuery MaskedInput plug-in that Gravity Forms uses, so it's very strange that they didn't suggest that as a solution.

As '.mask' is not part of core jQuery, it doesn't work for any form, you'll need a jQuery mask plug-in present or linked, such as the one above or the more recently updated jQuery Mask Plugin.
 

phukit

Well-known member
Trusted Uploader
Sep 30, 2018
190
320
63
It's indeed in the description of how to use the jQuery MaskedInput plug-in that Gravity Forms uses, so it's very strange that they didn't suggest that as a solution.

As '.mask' is not part of core jQuery, it doesn't work for any form, you'll need a jQuery mask plug-in present or linked, such as the one above or the more recently updated jQuery Mask Plugin.

Thanks for the clarification.

I am surprised too that they never mentioned this because its an easy solution.

Thanks
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu