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.
If you don’t want the user’s current locale name for the days to be valid, then just switch
toLocaleString()totoString(). But then, why don’t you just do this instead: