Basically, if four digits only (length) I check to make sure a number. If that passes, then all good. If more than 4 characters and not strictly a number, I run the spelling of month against an array of the 12 months, if that passes, I make sure the day number is there, and then confirm the year is behind the comma with a space.
I ended up with a lot of if/else, but ended up working. Was hoping there was more of a few-line option.
The numbers in the curly braces denote how many digits are allowed; also note the capturing parentheses to check the first word against that month array. However, @James_Hibbard’s route is certainly more user-friendly as it is far less restrictive.
Might a select dropdown (if not a datepicker) be a better choice for the form element ?
They lose their “ease of use” when they get lengthy, but for a limited number of options they may be easier to use than having a text input and banging around the possible values it might have.
Yeah, one reason I want to leave it “July 4, 2016” format is that the API was use on the same page will auto-fill the part of the form with that format as well, so they’d have to manually break it down to yyyy-mm-dd.