fix datefield (datetimefield) to return null for incorrect dates

This commit is contained in:
vitalets
2013-06-22 13:30:54 +04:00
parent 9cbcb0e99c
commit a00dac75ca
5 changed files with 135 additions and 49 deletions

@ -105,4 +105,31 @@ $(function () {
equal(e.text(), dview, 'text correct');
});
test("incorrect date", function () {
var d = '15.05.1984',
e = $('<a href="#" data-type="date" data-pk="1">'+d+'</a>').appendTo('#qunit-fixture').editable({
format: f,
viewformat: f
}),
nextD = '16.05.1984';
equal(frmt(e.data('editable').value, 'dd.mm.yyyy'), d, 'value correct');
e.click();
var p = tip(e);
ok(p.find('input').is(':visible'), 'input exists');
equal(p.find('input').val(), d, 'date set correct');
//enter incorrect date
p.find('input').val('abcde');
//submit
p.find('form').submit();
ok(!p.is(':visible'), 'popover closed');
equal(e.data('editable').value, null, 'date set to null');
equal(e.text(), $.fn.editable.defaults.emptytext , 'emptytext shown');
});
});