It is very difficult to check the date with a regular expression. How do you confirm, for example, on February 29? (it is difficult!)
Instead, I would use an inline object Date. It will always give a valid date. If you do:
var date = new Date(2010, 1, 30);
, . , , . >59, ..
:
var value = "22.05.2013 11:23:22";
var matches = value.match(/^(\d{2})\.(\d{2})\.(\d{4}) (\d{2}):(\d{2}):(\d{2})$/);
if (matches === null) {
} else{
var year = parseInt(matches[3], 10);
var month = parseInt(matches[2], 10) - 1;
var day = parseInt(matches[1], 10);
var hour = parseInt(matches[4], 10);
var minute = parseInt(matches[5], 10);
var second = parseInt(matches[6], 10);
var date = new Date(year, month, day, hour, minute, second);
if (date.getFullYear() !== year
|| date.getMonth() != month
|| date.getDate() !== day
|| date.getHours() !== hour
|| date.getMinutes() !== minute
|| date.getSeconds() !== second
) {
} else {
}
}
JSFiddle: http://jsfiddle.net/Evaqk/117/