{"action":"created","issue":{"url":"https://api.github.com/repos/xdan/datetimepicker/issues/426","repository_url":"https://api.github.com/repos/xdan/datetimepicker","labels_url":"https://api.github.com/repos/xdan/datetimepicker/issues/426/labels{/name}","comments_url":"https://api.github.com/repos/xdan/datetimepicker/issues/426/comments","events_url":"https://api.github.com/repos/xdan/datetimepicker/issues/426/events","html_url":"https://github.com/xdan/datetimepicker/pull/426","id":146321840,"number":426,"title":"Improvements for validation","user":{"login":"vzverev78","id":16628863,"avatar_url":"https://avatars.githubusercontent.com/u/16628863?v=3","gravatar_id":"","url":"https://api.github.com/users/vzverev78","html_url":"https://github.com/vzverev78","followers_url":"https://api.github.com/users/vzverev78/followers","following_url":"https://api.github.com/users/vzverev78/following{/other_user}","gists_url":"https://api.github.com/users/vzverev78/gists{/gist_id}","starred_url":"https://api.github.com/users/vzverev78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vzverev78/subscriptions","organizations_url":"https://api.github.com/users/vzverev78/orgs","repos_url":"https://api.github.com/users/vzverev78/repos","events_url":"https://api.github.com/users/vzverev78/events{/privacy}","received_events_url":"https://api.github.com/users/vzverev78/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-06T13:57:01Z","updated_at":"2016-04-08T12:25:01Z","closed_at":"2016-04-06T14:23:24Z","pull_request":{"url":"https://api.github.com/repos/xdan/datetimepicker/pulls/426","html_url":"https://github.com/xdan/datetimepicker/pull/426","diff_url":"https://github.com/xdan/datetimepicker/pull/426.diff","patch_url":"https://github.com/xdan/datetimepicker/pull/426.patch"},"body":"Corrected documentation for using MomentJS for validation.\r\nImproved code to see parsed date/time after validation because validation by php-date-formatter may ignore invalid parts and confuse user on what they see vs what they get. \r\nSee https://github.com/xdan/datetimepicker/issues/425 for details.\r\n"},"comment":{"url":"https://api.github.com/repos/xdan/datetimepicker/issues/comments/207411028","html_url":"https://github.com/xdan/datetimepicker/pull/426#issuecomment-207411028","issue_url":"https://api.github.com/repos/xdan/datetimepicker/issues/426","id":207411028,"user":{"login":"vzverev78","id":16628863,"avatar_url":"https://avatars.githubusercontent.com/u/16628863?v=3","gravatar_id":"","url":"https://api.github.com/users/vzverev78","html_url":"https://github.com/vzverev78","followers_url":"https://api.github.com/users/vzverev78/followers","following_url":"https://api.github.com/users/vzverev78/following{/other_user}","gists_url":"https://api.github.com/users/vzverev78/gists{/gist_id}","starred_url":"https://api.github.com/users/vzverev78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vzverev78/subscriptions","organizations_url":"https://api.github.com/users/vzverev78/orgs","repos_url":"https://api.github.com/users/vzverev78/repos","events_url":"https://api.github.com/users/vzverev78/events{/privacy}","received_events_url":"https://api.github.com/users/vzverev78/received_events","type":"User","site_admin":false},"created_at":"2016-04-08T12:25:01Z","updated_at":"2016-04-08T12:25:01Z","body":"I can add something like switch into validation part:\r\n```\r\n\t\t\t\t\t\t.on('blur.xdsoft', function () {\r\n\t\t\t\t\t\t\tif (options.allowBlank && (!$.trim($(this).val()).length || (typeof options.mask == \"string\" && $.trim($(this).val()) === options.mask.replace(/[0-9]/g, '_')))) {\r\n\t\t\t\t\t\t\t\t$(this).val(null);\r\n\t\t\t\t\t\t\t\tdatetimepicker.data('xdsoft_datetime').empty();\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\tvar f = options.format;\r\n\t\t\t\t\t\t\t\tif(!options.datepicker) {\r\n\t\t\t\t\t\t\t\t\tf = options.formatTime;\r\n\t\t\t\t\t\t\t\t} else if(!options.timepicker) {\r\n\t\t\t\t\t\t\t\t\tf = options.formatDate;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tvar d = dateHelper.parseDate($(this).val(), f);\r\n\t\t\t\t\t\t\t\tif (d) { // parseDate() may skip some invalid parts like date or time, so make it clear for user: show parsed date/time\r\n\t\t\t\t\t\t\t\t\t$(this).val(dateHelper.formatDate(d, f));\r\n\t\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\t\tvar splittedHours   = +([$(this).val()[0], $(this).val()[1]].join('')),\r\n\t\t\t\t\t\t\t\t\t\tsplittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));\r\n\t\r\n\t\t\t\t\t\t\t\t\t// parse the numbers as 0312 => 03:12\r\n\t\t\t\t\t\t\t\t\tif (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {\r\n\t\t\t\t\t\t\t\t\t\t$(this).val([splittedHours, splittedMinutes].map(function (item) {\r\n\t\t\t\t\t\t\t\t\t\t\treturn item > 9 ? item : '0' + item;\r\n\t\t\t\t\t\t\t\t\t\t}).join(':'));\r\n\t\t\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\t\t\t$(this).val(dateHelper.formatDate(_xdsoft_datetime.now(), f));\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tdatetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());\r\n\t\t\t\t\t\t\t}\r\n```\r\nIs this proper fix? You also have to add similar switches to all places where input field is updated.\r\nAlternative solution is to keep current format as object attribute and use it in all places."}}