How can I set alphabetic validation only in the full name field?

  • ipops
    Asked on July 4, 2017 at 9:49 AM
  • corupta
    Replied on July 4, 2017 at 10:06 AM

    Hello,

    Can you tell me what exactly what you did?

    For example, I just tried to add a short text field, selected alphabetic from the validation field in options tab of short text entry properties

    Than I changed the default value from the advanced tab in short text entry properties

    And I'm not able to enter alphanumeric, I can enter any value initially but when I click on another input field, it gives me the error "This field can only contain letters"

    So it's working properly.

    Can you tell me in detail of what you did, so I can reproduce the situation and solve the problem.

     

  • ipops
    Replied on July 4, 2017 at 10:30 AM

    Hi it is the name field, yes for other fields where I can select the input type there is not issue. Please see image below and user is able to submit the form like this

     

    How can I set alphabetic validation only in the full name field?  Image 1 Screenshot 20

     

    Thank you

  • corupta
    Replied on July 4, 2017 at 10:48 AM

    Yes, you are right, I think there's no validation option, how did you first selected the validation option for name field.

    A standard approach for this would be adding two short text fields one for First Name and the second for the Last Name

    However, it is possible to do so by injecting a custom javascript,

    If you are confident with this, I can write you a script to only allow alphanumeric characters, in the name field.

    However, you can do so only if you are copying the form to another website(your site)

    and you need to do so everytime you copy the source code from the form site (But I think you don't need to recopy source code of the form, and it will update itself automatically.)

    So to inject javascript you first need to go to publish -> embed -> source code and copy the long output. Then, you need to copy what I will post(if you want) to the end of it, and afterwards you should copy the whole thing and add it to your website.

    I recommend using the double short text approach, and if you don't put your form on a separate website you will not be able to do the javascript method.

    If you want to go with the javascript method, let me know and I'll write a small script for you.

    If you have any other questions, don't hesitate to tell me

  • Kevin Support Team Lead
    Replied on July 4, 2017 at 12:54 PM

    @ipops,

    As explained by @corupta, it is not possible to set a validation in the full name field; however, using a "Short Text Entry" field you will be able to do it. 

    Once you have added the field to your form, you should open the field settings, go to the options tab and set the validation there: 

    How can I set alphabetic validation only in the full name field?  Image 1 Screenshot 20

    If you decide to follow the advice about using the source code, this guide will help you getting it: How-to-get-the-Full-Source-Code-of-your-Form

    Here is a link that will help you with the needed JavaScript code to implement the validation using the source code: http://www.w3resource.com/javascript/form/all-letters-field.php 

    Hope this help.