jquery - Javascript RegEx: validate date time -


i not regex. being frustrated regular expression.

example:

i have following date time: 05/16/2013 12:00 am

i need javascript regex respect format: mm/dd/yyyy hh:mm [am/pm]

 var datereg = /^[0,1]?\d{1}\/(([0-2]?\d{1})|([3][0,1]{1}))\/(([1]{1}[9]{1}[9]{1}\d{1})|([2-9]{1}\d{3}))$/; if(!datereg.test(inputval)) {     $(this).after('<span class="error error-keyup-5">invalid date format.</span>'); } 

but code works date, not time. help.

your code snippet match date, there no atoms match time. regexp should be:

datereg = /^[0,1]?\d\/(([0-2]?\d)|([3][01]))\/((199\d)|([2-9]\d{3}))\s[0-2]?[0-9]:[0-5][0-9] (am|pm)?$/ 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -