Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 98
  • Last Modified:

Date input validation (Regular Expressions)

Hi guys,
I need to validate date input in range Day / Month / Year
    01/12/2016
Any chance to include ranges of
  days    (1-31) or (01, 02, 03, 04, 05,  . . .  31)
  month (1-12) or (01, 02, 03, 04, 05, . . .  12)
  years   (2016-2020)


^(\d{1,2})[\/](\d{1,2})[\/](\d{4})$

//how to fix this one
^(\d{1,2}0[1-9]|1[0-9]|3[0-1])[\/](\d{1,2}0[1-9]|1[0-2])[\/](\d{4}201[6-9]|202[0])$

Open in new window





Thanks for any info and help!

Darius
0
Darius
Asked:
Darius
1 Solution
 
Rgonzo1971Commented:
Hi,

ply try
^(0?[1-9]|[12]\d|3[01])[\/](0?[1-9]|1[0-2])[\/](201[6-9]|2020)$

Open in new window

or
^(0[1-9]|[12]\d|3[01])[\/](0[1-9]|1[0-2])[\/](201[6-9]|2020)$

Open in new window

Regards
1

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now