Gravity forms custom mask?

Hi,
I was wondering how can i do mask like this or is it even possible :

I would need to allow user to add field with numbers and letters and hyphen.
But seems that hyphen is not possible when using 9, a, *, ? etc…

So field should be able to enter:
999999-999a or 999999999
But i can’t input hyphen there if * is valid and when there is hyphen i can’t put alphabet there…

for example would like to add to field 100188-133m or 100188A133m but hyphen can’t be added there…

How can i allow also special characters like hyphen for example * or a ? or any other solutions?
Thank you for all the help!

This is a limitation in the masking plugin that GF utilizes. You might be better off limiting the input quantity as opposed to trying to mask it.

Or… If your Javascript chops are on point, you could interrupt the masking script as it’s firing and write your own special mask script using RegEx.

2 Likes

This might help, here’s the RegEx you would need to get valid results:

([0-9]{6}\D[0-9]{3}[a-zA-Z])

100188-133m	=> Valid

100188A133m => Valid

123456-741A	=> Valid 

1111111475A	=> Not Valid 

1234567A78F	=> Not Valid

123456d789d	=> Valid

You can do further testing with it here:

https://regexr.com/4lael

3 Likes

Thank you very much for the reply and advices. I will seek these options through and hopefully find solutions. I will post it here also if somebody else needs it for the future.