Restrict phone form field to numbers only and verify if email is valid format

yas
yas Member Posts: 8

Hi, how do I restrict and customise what can be entered in form fields. Could anyone help please? Thanks

  1. phone number: allow to only enter numbers,
  2. phone number: in which number format to correctly add a country code
  3. email:" verify that the email is valid
Tagged:

Best Answer

  • community_manager
    community_manager Administrator, Moderator Posts: 297 Duda Staff
    Answer ✓

    Hi!

    I am sorry to say that we currently do not have a way to validate certain fields in our contact form.

    If we take a closer look underneath the hood, we'll see that the input type for the telephone field has been set to "tel":


    So why does it allow letters? According to MDN Web Docs, "<input> elements of type tel are used to let the user enter and edit a telephone number. Unlike <input type="email"> and <input type="url">, the input value is not automatically validated to a particular format before the form can be submitted, because formats for telephone numbers vary so much around the world." So, this was done by design.

    I encourage you to checkout Paperform to see if they offer this functionality (available from our App Store and comes with a free 14-day trial) or add this as a feature request on our Ideas Board. Please make sure to be signed in.

Answers

  • courtneyquaresimo
    courtneyquaresimo Member Posts: 183 Leader

    Hey @yas

    Hoping I can help here.

    1. phone number: allow to only enter numbers - You can change the field type to phone number and then it will only allow numbers. See screenshot below.
    2. phone number: in which number format to correctly add a country code - I don't think there is an option to add a country code "option". They can add their country code if they want but I dont think there is a way to force that
    3. email:" verify that the email is valid - I don't think there is a feature for this either. A work around is just adding a second line and put "confirm email". This will prompt people to double check themselves

    Hope this helps somewhat.


  • yas
    yas Member Posts: 8

    Thanks. I have set it to phone number already, but when I use the field in preview it allows me to enter letters and the form still gets sent out (although it should come up with an error saying inout numbers only)