If this tutorial is not what you were looking for, you still have any questions, suggestions or concerns - feel free to let us know. Please help us to serve you better!

Your Name

Your Email

Your Message (required)

captcha

JS Animated. How to deal with validation of special characters in contact form rd-mailform

This tutorial is going to show you how to add special characters to the validation patterns for the contact form rd-mailform in JS Animated templates.

JS Animated. How to deal with validation of special characters in contact form rd-mailform

In order to add special characters to the validation patterns, you need to do the following steps:

  1. Open up the js/mailform/jquery.rd-mailform.min.js file using your favorite code editor.

  2. Locate the constraints array on line 71. There are 7 validation strategies: LettersOnly, NumbersOnly, NotEmpty, Email, Phone, Date, SelectRequired. Validation patterns are defined by the rule variable:

    JS_Animated._How_to_deal_with_validation_of_special_characters_in_contact_form_rd-mailform-1

  3. If you need to add special characters to the LettersOnly stategy, you need to insert them inside the square brackets of the rule pattern. For example, let’s add the character . Here is the original validation rule:

    rule: "^([a-zA-Zа-яА-ЯіїёІЇЁєЄҐґ\\s]{0,})$",
    

    This is the rule after inserting the character :

    rule: "^([人a-zA-Zа-яА-ЯіїёІЇЁєЄҐґ\\s]{0,})$",
    

    JS_Animated._How_to_deal_with_validation_of_special_characters_in_contact_form_rd-mailform-2

  4. Save the changes to the jquery.rd-mailform.min.js file. Make sure you save the file with the UTF-8 encoding.

  5. Now if you include the to the “Your Name” field, the script will consider it valid:

    JS_Animated._How_to_deal_with_validation_of_special_characters_in_contact_form_rd-mailform-3

  6. This way you can insert any character or a sequence of characters. You can also look up in the Internet to find a specific validation pattern for your language, which will include all characters. When submitting a search query you need to write it as “validation pattern for Arabic characters”. You can also visit this website. It will help you create a unicode regex for many languages.

Feel free to check the detailed video tutorial below:

JS Animated. How to deal with validation of special characters in contact form rd-mailform