How to disable space in the text field.

  • HPPolice
    Asked on March 14, 2020 at 12:55 AM

    Hi,

    I have a requirement in which I want the user to add only alphabets and numbers in my field and restrict use of space in between.

    I tried use to the validation also and kept it to 'Alphanumeric' option but still the field accepts the space and it is accepting the data.

    My field is 'Vehicle Number' in my form. Link of the form pasted below in the link url.

    Please help what is the issue.

  • Ferhat JotForm UI Developer
    Replied on March 14, 2020 at 2:12 AM

    Hi,

    You can prevent adding space by using Input Masking. You can easily shape the input format in order to prevent the user from typing wrong formats. You can follow the instructions to apply input masking

    Please let us know, If you need further help. 

  • aminnayel
    Replied on March 14, 2020 at 2:51 AM

    Hi there, @HPPolice!

    Just as @ferhat mentioned above, you can surely prevent spacing using input masking which is a JotForm built-in feature that you can easily apply to any of your form inputs, here's how:

    1. Open Form Builder, click on "Vehicle Number" text box, click on the "gear icon", then open the "OPTIONS" tab just as shown in the screenshot below.

    How to disable space in the text field Screenshot 30

    2. Scroll down until you find the "Input Mask" option, make sure to change it to "ON". Now, a new empty box will pop up right next to it. 

    How to disable space in the text field Screenshot 41

    3. To restrict space inputs into your "Vehicle Number" text box and allow only numbers, you have to set the input mask value to a number of hash symbols "#" that equals vehicle number digits. Example: if the vehicle number consists of 12 digits, then input mask value should be ############ with no spaces at all.

    For more information on input masking and restrictions, I recommend that you read this article. 

    Hope that answers your question.