Question about Pattern Validation

I created Contact Form using User Input fields which including Name, Email, Phone Number, Subject and Description fields.

Now, I would like to set pattern validation for both email & phone number fields, but I do not have a clue to to do that.

For example, for the email field, it must contain @xxxx.com, @xxx.net etc

And for phone number field, it must type in certain format, such as +1-123-456-7890 while

+1 is the country code
123 is the area code
the rest is the phone number itself.

Can I somehow do that?

Yes you can.

First, you can set regular expression validation on each of the input elements.

You can also use the validation APIs to customize validation.

Checkout