Created
December 14, 2012 19:46
Regular expression for validating time hh:mm am|pm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
re = /(^(\d{1,2}):(\d{2})\s?(?:am|pm)?)$|^\d{1}(?:am|pm)$/i; | |
var reminder = (attributes.reminder || '').replace(/\./g, '').replace(/\s/g, ''); | |
if (reminder !== '' && !reminder.match(re)) { | |
return "Enter valid time ie 3:30 pm or 5pm"; | |
} | |
/* match result | |
12:00 pm | |
6pm | |
6 pm | |
6:00 pm | |
3:00pm | |
5:15am | |
06:30 pm | |
06:30pm | |
06:30 pm | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will also match
98:63 pm
👎