spectrumcare
asked on
regex for MMMM yyyy
I need a JavaScript regex for full month name and 4 digit year. So February 2015 would pass but not Feb 2015 or 02/15.
This is what I have. The month part seems to be working but the year is not.
February 201 is going through as passing, but it should go into the fail since it is not in yyyy format.
This is what I have. The month part seems to be working but the year is not.
var thedayPattern =/^\b{?:January?|February?|March?|April?|May|June?|July?|August?|September?|October?|November?|December}\s\d{4}$/;
if(thedayPattern.test(document.getElementById("startDate").value))
{
alert("yes");
return false;
}
else
{
alert("no");
return false;
}
February 201 is going through as passing, but it should go into the fail since it is not in yyyy format.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are returning false twice. The second one should be true if no means that your test was OK. Or the other way around if you prefer.
ASKER
This worked great. Thanks