Accepting the String in normal text box and checking weather the srting is Date or not in javascrit
javascript code for validating the time accepted in the form of string
Collapse
X
-
I understood that much, but that's not enough. What would be considered valid, e.g. 12 hour format, 24 hour, just numbers and ":" or "AM/PM" too and so on.
You can use a regular expression to validate the field, but post your code. What have you managed so far?Comment
-
Since you refuse to provide more details, I'll just give you a general idea.
Match the format first using a regular expression, e.g.
then check each part individually for correctness, e.g. that hours is between 0 and 12, that minutes are between 00 and 59 and so on.Code:/^\d{1,2}\:\d{2}\:\d{2}(\s?(AM|PM))?$/iComment
Comment