Topic: Regular Expressions for jQuery Form Validation?
christopherbirwin pro asked 6 years ago
Expected behavior
When a user enters an incorrect format for an email address and tries to submit the form, an error displays, which indicates the information entered is invalid and prevents the form doesn't submit (i.e., it allows the use of regular expresssions).
Actual behavior
When a user enters an incorrect format for an email address and tries to submit the form, an error doesn't display displays, which indicates the information entered is invalid, and the form is not prevented from submitting (i.e., there doesn't appear to be a way to use regular expressions).
Resources (screenshots, code snippets etc.)
(The link includes sample code.)
christopherbirwin pro answered 6 years ago
Never mind! I didn't realized it's built into HTML5:
I found the regex I needed here:
csax answered 5 years ago
Just FYI,
You could use the pattern attribute, which takes regex
<input type="text" name="ssn"
pattern="^\d{3}-\d{2}-\d{4}$"
title="The Social Security Number" />
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: 4.8.2
- Device: Desktop PC
- Browser: All
- OS: Windows
- Provided sample code: No
- Provided link: Yes