DEV Community

Cover image for Client side validation with the Pattern Attribute
Ankit Beniwal
Ankit Beniwal

Posted on

1 2

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

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay