Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Regular Expressions for jQuery Form Validation?

christopherbirwin pro asked 5 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.)

Snippet of an Example Form

(The link includes sample code.)


csax free 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" />

christopherbirwin pro answered 5 years ago


Never mind! I didn't realized it's built into HTML5:

HTML 5 Validation

I found the regex I needed here:

RegEx Search



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: 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