Client side validation with the Pattern Attribute

ankitbeniwal

Ankit Beniwal

Posted on January 11, 2020

Client side validation with the Pattern Attribute

Hello Devmates, 👋

Today I learned about the client side validation using

The Pattern Attribute

It is used to provide a regular expression (regex) to the input element of HTML. This regex is automatically checked just like a required attribute is checked in HTML.

It works with the input types including text, search, url, tel, email, and password.

Here is a pen demonstrating an email input which only accept secure emails:

Note: Never rely on only client side validation. Server Side validation is important from the security perspective. (I know this is obvious, Don't give me that look 😐)

You may want to connect with me on twitter or checkout my #devdiaries on instagram.

Good night 😴😴 from India

Reference:
https://www.w3schools.com/html/html_form_attributes.asp

💖 💪 🙅 🚩
ankitbeniwal
Ankit Beniwal

Posted on January 11, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

TIL Dev Tools can be Undocked
todayilearned TIL Dev Tools can be Undocked

March 26, 2021

5 CSS Tricks I Used This Week
css 5 CSS Tricks I Used This Week

February 4, 2021

What is Shadow DOM??
todayilearned What is Shadow DOM??

August 4, 2020