Fix validation so dates without trailing text fail validation

GessWurker
GessWurker used Ask the Experts™
on
I need to prevent "orphan dates" being submitted in form. The attached form is prevents bad dates from being submitted, but it does not block entries that contain ONLY a date. All lines should have a valid date followed by some text.

Example: A line that only has a date, like this:

·12/12/2019

Should not pass validation.

These lines are good:

·10/23/2019 - test
·10/24/2019 - testing again

Here is test content (note, the bullet character must be included):

·10/23/2019 - test
·10/24/2019 - testing again
·10/01/2019 - here's another test
·12/03/2019 - sort this one too
·12/1/2019 - bad date should be caught
·12/12/2019
·12/x/2019

By the time all validation is done, all acceptable entries (i.e., valid date followed by text) should be accepted and properly sorted.

Who can help with this validation issue?

Thanks!
sort_test.htm
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
Commented:
hmm, I would try a different validation regex: /^·?\d{2}([\-\/.])\d{2}\1\d{4} - (.)+/. The number of matches must be equal to the number of lines.

Author

Commented:
Perfect! Thanks!

Author

Commented:
Did the trick!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial