After reviewing Time validation question by Amra
I have created a regexp for my needs
var re = /^\s*([01]?\d|1[0-2]):?([00,30]\d)\s*$/;
my intention is to allow only the hour and half an hour interval times
ie: “12:00″,”01:00″,”12:30″,”01:30”, etc
This regexp almost works, it returns false when “01:10” but it returns the value when i enter “01:01″….”01.09”, it has to be false.
Please help me
And please describe this regexp in detail..
[00,30]does not do what you think it does.[]groups in a regexp are character classes – sets of characters that can be matched, for instance[a-z]matches a single lowercase letter, not the string “a-z”.Try this instead:
(00|30)matches either00or30and nothing else –|is the regex “or” operator.