Validate HTML Inputs w/ Pattern Attribute

Validate HTML Inputs w/ Pattern Attribute

Add a simple pattern and title attribute on any HTML input to only allow a specific value or part of a value to be accepted. This can be used to validate emails from a specific domain like “@example.com” or only accept links that include a specific string. The title attribute allows a custom message appear in a browser default tooltip if the email entered isn’t valid.

Within the pattern attribute we use regex to determine what value match is approved. You can use regex to match just about anything, so this general approach can also be used to match other specific values in any input.

Have feedback or a question related to this item? Drop us some feedback!

Curated: 
5.4.23

Similar items

Items
2777
Search

Email Address Input Validation

12.15.23

Dark/Light Mode Favicon Images

9.12.23

Redirect Form on Submit and Pass Input Value to URL

10.23.22

Birthday Age Gate Modal Overlay

5.10.22

Vimeo Video as Background

9.20.21

Restock

View Restock

Add to Calendar Button

8.12.20

Hide/Show Element From <select>

1.6.20

Reload Page After Form Submit

12.4.19

Custom Tag Form Spam Prevention

1.16.24

Show a Preloader Only Once Per Day

1.3.24

Remove https:// From Text Link

9.5.23

Run Javascript on Mobile Only

7.26.23

Skip to Main Nav Link

6.14.23

Detect and Don't Redirect Search Bots

2.28.23

Randomize Button Text on Click

1.12.23

Get Website Meta Data w/ Airtable Script

1.10.23

Get YouTube Thumbnails w/ Airtable Script

12.22.22

Compress Images w/ Airtable Script

10.10.22

Get Image Size w/ Airtable Script

10.10.22

Simple Countdown to Date/Time

10.6.22

CSS Logo Marquee / Ticker

5.25.22

View All or Show Less List Pagination

4.11.22

Set Referrer URL as Hidden Input

3.28.22

Bummer, no results

Try a different search/filter combo, or drop us some feedback if there is something missing you would love to see!

Reset filters

Subscribe for updates

Get updates on the latest curated resources and be the first to hear of new features.

Subscribe