1

Possible Duplicate:
Best way to validate date string format via jQuery

Date validation : dd/mm/yyyy or d/m/yyyy

/^({|()?[0-9]{1,2}\/([0-9]{1,2}\/[0-9]{4}))+$/

But how to set max day, max month, year rules ? (max day = 31, max month = 12, year = 1900-2012)


Name validation :

/[a-zA-Zøæå]{2,40}$/

Rules : Letter a-z A-Z , Ø,Æ,Å (min=2, max=40)

Can you review this regex rule ? + this dosen`t work

Community
  • 1
  • 1
l2aelba
  • 21,591
  • 22
  • 102
  • 138
  • 2
    The solution for dates is not to use regex. Take a look at my answer to this question http://stackoverflow.com/questions/11218181/best-way-to-validate-date-string-format-via-jquery/11218271#11218271 – elclanrs Aug 24 '12 at 07:59
  • 2
    Name validation? Looking at your expression Jean-Michelle O'Connel would not be a valid name. A name _can_ contain an apostrophe, a dash, spaces and dots. – Elias Van Ootegem Aug 24 '12 at 08:05
  • Oh, so i can use only name.length ? – l2aelba Aug 24 '12 at 08:07
  • 1
    Also avoiding special chars like /%$, numbers & so on... – Gabber Aug 24 '12 at 08:19

1 Answers1

0

Best way to validate date string format via jQuery

Community
  • 1
  • 1
l2aelba
  • 21,591
  • 22
  • 102
  • 138