Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPForms is funded, why it matters, and how you can support us.

Claire Broadley

Claire is the Content Manager for the WPForms team. She has 13+ years' experience writing about WordPress and web hosting. Learn More

The Best WordPress Drag and Drop Form Builder Plugin

Easy, Fast, and Secure. Join over 6 million website owners who trust WPForms.

Please enable JavaScript in your browser to complete this form.

43 comments on “How to Limit Form Fields With Input Masks (+Examples)

  1. Can i define a min / max length e.g. for a single line Field and will this be validated correctly?

  2. What happens if you don’t have a field named Input Mask? There isn’t anything under the CSS Classes field under Advanced Options?

    1. Hi Dianne,

      I apologize for any trouble with this! When adding an input mask, be sure you’re using a Single Line Text field (this is currently the only field type that allows input masks). Also, this is a more recent feature so be sure that your WPForms plugin is fully up to date.

      If you give this a try and still don’t see the options you’re expecting, please get in touch so we can assist further. If you have a WPForms license, you have access to our email support, so please submit a support ticket.

      Otherwise, we provide limited complimentary support in the WPForms Lite WordPress.org support forum.

      Thanks 🙂

  3. Hi there, in this article: https://wpforms.com/docs/how-to-use-custom-input-masks/

    You use the example input mask for an email address at “mysite.com”

    Mask: *[*{0,50}]@mysite.com
    Example Input: [email protected] or [email protected]

    But what if your website has the letter “a” in it? For example…

    Using this layer mask: *[*{0,50}]@mydomain.com
    actually renders a field that has a blank for the “a” in domain.
    Example input: _______@mydom_in.com

    How do I format the layer mask so that the entire string “mydomain.com” stays intact?

    Thanks in advance for your help!

    1. Hi Re,

      I’m sorry for the trouble with that! I’ve replicated the issue you described, and shared it with our team to work on a fix. Thanks for letting us know so we can get this resolved! 🙂

  4. Hi there. I want to use the input mask tool to limit the characters entry in some of my fields.

    I’m using this mask: *[*{0,30}].

    However, it doesn’t include the “spaces” as a character.

    What input mask can I use to include the spaces as a character in my 30 characters limit?

  5. I am having the same issue as RE CARLSON

    But what if your website has the letter “a” in it?

    Do you have a fix for this?
    Thanks.

    1. Hi Allan,

      I’ve got good news — we do have a solution for this 🙂

      In order to add an “a” without turning it into part of the input area, you can escape it using `\\`. For example, if you were to enter this as your input mask: `this is \\a test aaa`, it would end up being: “this is a test ___”.

      So just be sure to put that double backslash in from of any A, a, or 9 that you’d like to keep as is (not convert into a _).

      I hope this helps! 🙂

  6. hello,

    I need uppercase alphanumeric (0-9 or A-Z) to combine with space between characters. Apparently “&” does not allow any spacing

    1. Hi Elyas,

      We don’t have a special character to allow for spaces; instead, you can simply add a space in between whatever & characters you’d like, so you can have the input mask field read as “&&&& &&&&.”

      I hope this helps! 🙂

      1. How can i do field accept only starting with only 6-9 numbers range. I’m using Purchased WPForms Basic.

        Example
        7898981226
        8985607458
        9989878774

      2. Hi Munaf!

        You can create a custom input mask for the Single Line Text field, however, there is no built-in option to use the numbers range there.
        So you can have it like this for example “\\799999” and it will allow only “7” in the beginning and then 5 more any digits, but we don’t have rules to choose 7 OR 8 OR 9 there in the beginning, unfortunately.
        And in case it helps, we have one more great tutorial on how to use custom input mask in WPForms here

        I apologize for any confusion!

        Have a good one 🙂

  7. Estou iniciando o uso do WPFroms ainda de forma gratuita para testes de compatibilidade com soluções que já tenho implantadas, contudo tentando personalizar uma mascara simples sugerida por vocês como “https://www.f\\acebook.com/*{1,22}” em um campo de “texto de linha unica” percebo que não são aceitos caracteres especiais simples como ? . ou / ; isso é uma limitação proposital impostas a usuários gratuitos ou poderiam me informar por qual simbolo deveria substituir o de * para permitir a entrada de caracteres especiais na mascara.

    1. Hey Waqas- If you have number of digits fixed, then it is doable. For example, this input mask will show 9 digits and a comma after every 3 digits 999\,999\,999

      I hope this helps!

  8. Hi, my input masks seem to not work anymore, the text fields just let write whatever although masks are active. Any help please? thnk u.

  9. Hi,

    I am creating a name field with single line text & only alphabets and spaces should be added. For this, I have added input mast as a{1,50}. This accepts alphabets, but spaces can’t add, Please give me a solution for this.

    1. Hi Amrita! I apologize, but input masks would not be suitable for this kind of use case, as it is meant to provide a specific structure to the input as well, for example a phone number or ID number. Spaces would not be able to be utilized in an input mask.

      To do what you’re looking for would require custom coding (usually jQuery or JavaScript), however I apologize as we aren’t able to provide support for this degree of customization. This thread might be able to give you some ideas though.

      I’m sorry that we’re not able to provide a solution for this but if you have any further questions, please contact us if you have an active subscription. If you do not, don’t hesitate to drop us some questions in our support forums.

  10. Hey guys

    how do i create a mask in this way?

    +55 (99) 9 9999-9999 or +55 (99) 9999-9999 on the same input.

    tks,

    1. Hi there! It seems you’ve posted this question in multiple articles, so I’ll be addressing it in one location here.

      I apologize but it isn’t possible to specify where the optional number would be placed, as the input mask operates by the sequence that they are entered. Technically, the optional number could be kept optional, but it would mean that your users would need to “skip” that character by entering a space in that character position, and then continuing on to fill the rest of the field.

      It should be possible with some custom coding, however I’m sorry such customizations are outside the scope of our support. In case you’d like to look into custom development options, we highly recommend using Codeable. Codeable screens all developers for you to make sure that they’re highly skilled and communicative, and then also helps guide the entire process of connecting and communicating with a best-fit developer.

      Here’s our tutorial on using Codeable, which provides more details on how this process works.

      Or if you’d like a team that you can continue coming back to (longer term) for custom development help, you might also consider checking out WPBuffs.

      I hope this helps to clarify 🙂 If you have any further questions about this, please contact us if you have an active subscription. If you do not, don’t hesitate to drop us some questions in our support forums.

  11. The phone number element doesn’t offer input masking, is that feature possible?

    We like to be able to use input masking on the phone number element because it offers the country code selector, whereas a regular text input does not (although it does offer input masking).

    Thanks,
    Mark

    1. Hi Mark,

      We do not have an inbuilt feature to set the custom mask for the Phone field. However, this can be achieved using the Single Line Text Field and setting the custom input mask as shown here

      Hope this helps! 🙂

  12. Is it possible to require a decimal input in the numeric field?

    So a user is always required to enter whole+ x-number of decimals?

    For example:

    0.015
    0.792
    0.28
    1.256

    1. Hey Cristian – you can make use of the following Input Mask to achieve that: $ [[9],999.99].

      I hope this helps!

    1. Hey Kashmira – you can make use of the following Input Mask to achieve that:EMP2[9999].

      I hope this helps!

  13. Hi! How can i create an input mask for optional amount
    for example $1,000,000 or $250,000 adding a comma in between depending the amount?

    1. Hey Mariana, unfortunately, we do not have a built-in option for optional format with input mask as you’ve described. I do agree it would be super helpful, though. I’ve made a note of the feature request and we’ll keep it on our radar as we plan out our roadmap for the future.

      Thanks and have a good one!

  14. Hey there – can I use an input mask to NOT allow spaces?
    e.g. if a user types in “AA 9999” the mask will force “AA9999”?
    Or a trailing/leading space like “AA9999[_]” will go in as “AA9999” without the space?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.