From the course: HTML and CSS: Creating Forms

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Pattern attribute

Pattern attribute

- [Instructor] The pattern attribute is really useful for client-side validation. While we looked at some basic types of validation earlier in the course, such as validating an email address or making sure a number is in a specific range, a pattern is an attribute that lets you be very specific about what you are expecting in a form field. The pattern attribute is used with input elements. The pattern attribute defines a regular expression, or RegEx, which is a sequence of characters that describe a pattern that needs to be matched. Regular expressions are a concept from computer science. This isn't something that's specific to HTML. I'll show you some examples. So this is the pattern attribute that you would have on the input element. So what you see here, inside the quotation marks, we have square brackets and that signifies what kind of characters can be in this pattern. So we have lowercase A to Z, uppercase A to Z and 0 to 9, which means any lowercase or uppercase letter or any…

Contents