What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.

  • Profile Image

    How can we set validation for no space in the text field.

    Asked by NeetaKapadia on December 11, 2011 at 06:26 AM

    I have a field where I would like the user to enter only alphanumeric text without any space. How do I do that. Can you please let me know how to achieve that

  • Profile Image

    Answered by pinoytech on December 11, 2011 at 09:47 AM

    Hi NeetaKapadia,


    Here's how you can set the validation for your text field:

    1. Open your form 

    2. Click on the "user" text field

    3. Click on "Properties: Name" on the top menu

    4. Click on the "Validation" icon and set to "AlphaNumeric"


    Hope this will help you. Thank you for using JotForm!



  • Profile Image
    JotForm Support

    Answered by idarktech on December 11, 2011 at 09:58 AM



    Unfortunately, we don't have direct tool for no space validation but If you like, you can try this workaround. In order to achieve that you need to download your form's full source code, here's a guide for that: http://www.jotform.com/help/104-How-to-download-a-source-code-of-your-form 

    After downloading your form's source code, open the html file (can be found on the downloaded form files).

    On the html code, under <head> tag please add the code below:


    <script type="text/javascript">

    function nospaces(t){


    alert('Sorry, you are not allowed to enter any spaces');






    After that, add this code onkeyup="nospaces(this)" inside the Text Box code. (This should be the Text Box where you don't want to allow any spaces. Please see sample structure below.)

    <input type="text" name ="textbox" id="textbox" onkeyup="nospaces(this)">

    Here's sample demo: Click HERE

    Let me know if you have further questions. Thanks.


  • Profile Image

    Answered by Fahim on October 14, 2012 at 07:01 AM

    Nice code. Thanks idarktech

  • Profile Image

    Answered by moonzkie on October 14, 2012 at 07:20 AM

    In behalf of my colleague, we're glad to be of help, if you have further questions feel free to contact us.

    Thanks for using JotForm!

  • Profile Image

    Answered by Anup Shaji on January 11, 2013 at 06:34 AM

    Thankx idarktech... this was helpful....

  • Profile Image

    Answered by aarthy d on September 18, 2013 at 01:27 AM


  • Profile Image

    Answered by aarthy on September 18, 2013 at 01:30 AM

    thank uu.........

  • Profile Image

    Answered by munimohan on September 18, 2013 at 08:14 AM

    ThankU man..............


  • Profile Image

    Answered by sushma  on October 01, 2014 at 02:27 AM

    thank you..

  • Profile Image

    Answered by siva  on February 11, 2015 at 12:59 PM

    what is the meaning of symbols in code

    (if(t.value.match(/\s/g)))      t.value=t.value.replace(/\s/g,'')

    please give the answer 

    thank you

  • Profile Image

    Answered by Ben on February 11, 2015 at 02:04 PM

    Hi Siva,

    The code above is called regex code that is used to find and if found remove space characters from the text.

    Now, as this is a very old thread, if you have any further questions in regards to this, please let us know by opening your own thread.

    Thank you.

  • Profile Image

    Answered by thilina  on July 21, 2015 at 05:20 AM


  • Profile Image

    Answered by Yasir Ihsan  on August 18, 2015 at 04:11 AM


    I was searching for the long time no one put executable code. Every person is misguiding. Thanks for the code it is 100% working and running fine on my page.

  • Profile Image

    Answered by Faisal  on January 21, 2016 at 02:21 AM

    Thanks Bro..Awesome It Is!

  • Profile Image

    Answered by pavan  on March 28, 2016 at 07:47 AM

    Thankyou it was helpful

  • Profile Image

    Answered by   on August 18, 2016 at 01:38 AM


  • Profile Image

    Answered by Farhad  on November 13, 2016 at 01:08 AM

    Thanks It's worked well

  • Profile Image

    Answered by Hari  on January 04, 2017 at 11:15 PM

    my validation needs some space below the text field. the validation text is postioning
  • Profile Image
    JotForm Support

    Answered by BJoanna on January 05, 2017 at 02:11 AM


    I have moved your question to separate thread and we will provide you an answer there shortly.