validation on Date field
validation on Date field
Hi there,
I'm testing a set of data that incudes a DATE field. Loading the DataTable with the appropriate date and format works just fine, however, when I attempt to EDIT a record, I deliberately set the date field in a wrong format to force the validation to return a FieldError, which I do get:
{"id":-1,"error":"","fieldErrors":[{"name":"ISSUED","status":"Date is not in the expected format"}],"data":[]}
The edit form doesn't display the message as expected in red font below the field. Have you ever come across this before?
Here's my JS file in case this helps:
[code]
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "http://localhost:8080/JQuery/join3.jsp",
"domTable": "#employees",
"fields": [ {
"label": "LASTNAME:",
"name": "LASTNAME",
"type": "text"
}, {
"label": "FIRSTNAME:",
"name": "FIRSTNAME",
"type": "text"
}, {
"label": "MOBILE:",
"name": "mobile.MOBILE_NUMBER",
"type": "text"
}, {
"label": "MOBILE TYPE:",
"name": "mobile.TYPE",
"type": "text"
}, {
"label": "ISSUED:",
"name": "mobile.ISSUED",
"type": "date",
"dateFormat": 'D, d M y'
}
]
} );
$('#employees').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<"H"Tfr>t<"F"ip>',
"sAjaxSource": "http://localhost:8080/JQuery/join3.jsp",
"aoColumns": [
{ "mData": "LASTNAME" },
{ "mData": "FIRSTNAME" },
{ "mData": "mobile.MOBILE_NUMBER",
"sDefaultContent": "" },
{ "mData": "mobile.TYPE",
"sDefaultContent": "" },
{ "mData": "mobile.ISSUED",
"sDefaultContent": ""}
],
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
} );
} );
[/code]
I'm testing a set of data that incudes a DATE field. Loading the DataTable with the appropriate date and format works just fine, however, when I attempt to EDIT a record, I deliberately set the date field in a wrong format to force the validation to return a FieldError, which I do get:
{"id":-1,"error":"","fieldErrors":[{"name":"ISSUED","status":"Date is not in the expected format"}],"data":[]}
The edit form doesn't display the message as expected in red font below the field. Have you ever come across this before?
Here's my JS file in case this helps:
[code]
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "http://localhost:8080/JQuery/join3.jsp",
"domTable": "#employees",
"fields": [ {
"label": "LASTNAME:",
"name": "LASTNAME",
"type": "text"
}, {
"label": "FIRSTNAME:",
"name": "FIRSTNAME",
"type": "text"
}, {
"label": "MOBILE:",
"name": "mobile.MOBILE_NUMBER",
"type": "text"
}, {
"label": "MOBILE TYPE:",
"name": "mobile.TYPE",
"type": "text"
}, {
"label": "ISSUED:",
"name": "mobile.ISSUED",
"type": "date",
"dateFormat": 'D, d M y'
}
]
} );
$('#employees').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<"H"Tfr>t<"F"ip>',
"sAjaxSource": "http://localhost:8080/JQuery/join3.jsp",
"aoColumns": [
{ "mData": "LASTNAME" },
{ "mData": "FIRSTNAME" },
{ "mData": "mobile.MOBILE_NUMBER",
"sDefaultContent": "" },
{ "mData": "mobile.TYPE",
"sDefaultContent": "" },
{ "mData": "mobile.ISSUED",
"sDefaultContent": ""}
],
"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
} );
} );
[/code]
This discussion has been closed.
Replies
Alan
Allan
Alan