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 8343999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:14:05+00:00 2026-06-09T06:14:05+00:00

I need to validate a primitive date of birth field input in the format

  • 0

I need to validate a primitive date of birth field input in the format of:

‘mmmyyyy’

Where the first 3 characters of the string must be an acceptable 3-letter abbreviation of the months of the year.
It can be lowercase, or uppercase, or a mix of any so long as it spells out jan or feb or mar etc etc etc.
There is no built-in method that I am aware of that has a ready array of this specific format of a month to be able compare against user input. I was thinking that I could maybe use the localeCompare() method in a for loop to test if the output is not 0 then append an error message accordingly.

  • 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-09T06:14:07+00:00Added an answer on June 9, 2026 at 6:14 am
    function dateTester() {
       var d = new Date(),
          i,
          mo = [],
          moIsValid;
       for (i = 0; i < 12; i += 1) {
          d.setMonth(i);
          mo.push(d.toLocaleString().split(' ')[1].substr(0, 3));
       }
       return new RegExp('^(' + mo.join('|') + ')', 'i');
    }
    
    var moIsValid = dateTester();
    alert(moIsValid.test('fEb1992'));
    

    If you don’t want the user’s current locale name for the days to be valid, then just switch toLocaleString() to toString(). But then, why don’t you just do this instead:

    var moIsValid = /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i;
    alert(moIsValid.test('fEb1992'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to validate input to my application. The input is a formatted string
I need validate the given input String is a valid Timestamp in milliseconds. For
I need to validate and input string client side. Here is an example of
I need to validate a date/time field on a webpage but want it to
I need to validate a date field which is being entered by a user
I need to validate two user input fields against each other in seam. Field1
I need validate the dynamically appended input text box for the below code $(#btnadd).click(function()
I need to validate a string that contains XML Data, there is no schema
I need to validate 3 or more input fields (required at lest one). For
I need to validate an XML string (and not a file) against a DTD

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.