Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:40:48+00:00 2026-06-04T15:40:48+00:00

I am trying to use a javascript regular expression to validate date of birth

  • 0

I am trying to use a javascript regular expression to validate date of birth textbox. here is my code

var patt=/[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}/;
alert(patt.test("1985/08/03"));

and the error said: SyntaxEror: Unexpected token {

I don’t understand why, this pattern works fine in the asp.net RegularExpressionValidator controller.
Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:40:50+00:00Added an answer on June 4, 2026 at 3:40 pm

    You need to escape the / characters, otherwise the interpreter sees the first one and thinks that’s the end of the regexp.

    You should also put anchors in your regexp to ensure it matches the whole string, and doesn’t match any string which happens to contain that pattern.

    For brevity you can use \d instead of [0-9], too:

    var patt = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
    

    NB: your sample doesn’t work – you’ve put the year first, but the RE is expecting it to be last.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am using razor and trying to use regular expression to validate email
I am trying to figure out how to use a regular expression to validate
I am trying to use some rails code withing a javascript and need to
I am having problems trying to use the regular expression that I used in
I am trying use javascript regular expressions to do some matching and I found
Trying to learn jquery here so I took a regular javascript snippet that loops
I am trying to use JavaScript in an Android webview. I used following code.
I'm trying to use javascript to code up a dynamic form, where elements are
I'm trying to use JavaScript to convert a date object into a valid MySQL
I'm trying to use a regular expression validation using .match for email validation and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.