From the course: Building Great Forms with HTML and CSS
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Input restrictions: Pattern
From the course: Building Great Forms with HTML and CSS
Input restrictions: Pattern
- [Instructor] As we have seen, the HTML5 specification has made validation that much easier with the introduction of the new input types, such as email, URL and tel. And these also come packaged up with predefined validation. Whenever the value given is not met with the expected formatting , these input types will throw an error message, thus preventing submission. However, expecting every possible input scenario to be catered for is impractical. What if you have a username "zipcode", "credit card" or any other special data types that are not specified as standard input types? How do we validate those inputs? This is where the attribute pattern comes into play. The pattern attribute is only applicable on the input element. It allows us to define our own rule to validate the input value using regular expressions or regex. Again, if the value does not match the specified pattern, the input will throw an error. Regular…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Fieldsets and legends5m 15s
-
(Locked)
Working with labels5m 35s
-
(Locked)
New HTML5 form tags5m 58s
-
New input types6m 23s
-
(Locked)
New input attributes3m 54s
-
(Locked)
More input attributes6m 52s
-
(Locked)
Form validate options4m 56s
-
(Locked)
Input restrictions: Pattern11m 24s
-
(Locked)
Buttons7m 15s
-
(Locked)
Autocomplete3m 30s
-
-
-
-
-
-
-
-
-