validation on Date field

validation on Date field

ashiersashiers Posts: 101Questions: 8Answers: 7
edited June 2013 in Editor
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]

Replies

  • ashiersashiers Posts: 101Questions: 8Answers: 7
    Actually, I think I see my error. Because this field is being obtained from a Join, the field name includes the table name. So it's really supposed to be "mobile.ISSUED". I'm going to check my code again and see if that is the problem.

    Alan
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    That's correct - whatever is in the `name` property is the name that should be given in the error condition flag.

    Allan
  • ashiersashiers Posts: 101Questions: 8Answers: 7
    Yep! That was it! Great minds think alike don't they! Sometimes in the heat of the moment you just can't see the forest for the trees.

    Alan
This discussion has been closed.