Custom Validation with Datatables
Custom Validation with Datatables
asifhussain
Posts: 7Questions: 0Answers: 0
Hi,
I am using jquery.validate's custom validation with Datatables. I am trying to send either the row Id of the edited cell or the old value in the cell and i am not able to :(
Can anyone help? its urgent :(
this is my validator -
$.validator.addMethod("invalidHours", function(value, element, sOriginalText){
cTable = $('#example2').dataTable();
alert('sOldValue: '+sOriginalText);
var currentSubTask;
$('#example2 tbody tr').each( function () {
if ( cTable.fnIsOpen(this) ) {
currentSubTask = this.id;
return false;
}
} );
var result;
var uri = "/servlets/ProjectScopeScratchPadServlet";
var params = "?FWAction=validateJobTitleHours&sessionId="+sessionId+"&enteredJobTitleHours="+value+"¤tSubTask="+currentSubTask;
jQuery.ajaxSetup({async:false, cache:false});
$.get(uri+params, function(data, textStatus) {
result = data;
});
if(result == 1){
return true;
}
}, 'Please enter valid Job Title Hours');
and this is my cell
oValidationOptions :
{
rules:{
value: {
digits: true,
invalidHours: sOriginalText
}
},
messages: {
value: {
digits: "Please Enter Valid number of Job Title Hours",
invalidHours: "Please make sure that Job Title Hours sum up to Activity Hours"
}
}
},
I am using jquery.validate's custom validation with Datatables. I am trying to send either the row Id of the edited cell or the old value in the cell and i am not able to :(
Can anyone help? its urgent :(
this is my validator -
$.validator.addMethod("invalidHours", function(value, element, sOriginalText){
cTable = $('#example2').dataTable();
alert('sOldValue: '+sOriginalText);
var currentSubTask;
$('#example2 tbody tr').each( function () {
if ( cTable.fnIsOpen(this) ) {
currentSubTask = this.id;
return false;
}
} );
var result;
var uri = "/servlets/ProjectScopeScratchPadServlet";
var params = "?FWAction=validateJobTitleHours&sessionId="+sessionId+"&enteredJobTitleHours="+value+"¤tSubTask="+currentSubTask;
jQuery.ajaxSetup({async:false, cache:false});
$.get(uri+params, function(data, textStatus) {
result = data;
});
if(result == 1){
return true;
}
}, 'Please enter valid Job Title Hours');
and this is my cell
oValidationOptions :
{
rules:{
value: {
digits: true,
invalidHours: sOriginalText
}
},
messages: {
value: {
digits: "Please Enter Valid number of Job Title Hours",
invalidHours: "Please make sure that Job Title Hours sum up to Activity Hours"
}
}
},
This discussion has been closed.