Reputation: 1
Currently I am using Jeditable version 1.6.1 in my project. I am trying to use the onkeyup event for validating user entered values in the input text field. When i am trying to use onkeyup event, it is not working. I am not sure whether Jeditable supports this event or not. Could you please help me with this problem?
Regards PJ
Upvotes: 0
Views: 919
Reputation: 1
TRY THIS, GOOD LUCK
input.keypress(function(e) {
var key = window.Event ? e.which : e.keyCode
return (key >= 48 && key <= 57)
});
$('td.editable_class', oTable.fnGetNodes()).editable('editable.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
window.location.reload();
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition( this )[2]
};
},
"height": "40px"
});
Upvotes: 0
Reputation: 11
And this would the the helper method that validates whether or not the key is a number:
var numbersOnly = function (e, decimal) {
var key;
var keychar;
if (window.event) {
key = window.event.keyCode;
}
else if (e) {
key = e.which;
}
else {
return true;
}
keychar = String.fromCharCode(key);
if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) {
return true;
}
else if ((("0123456789").indexOf(keychar) > -1)) {
return true;
}
else if (decimal && (keychar == ".")) {
return true;
}
else
return false;
};
Upvotes: 0
Reputation: 11
This worked for me.
$.editable.addInputType('dernumber', {
element: $.editable.types.text.element,
plugin: function (settings, original) {
$('input', this).bind('keypress', function (event) {
return numbersOnly(event, false);
});
}
});
$('.loremipsum').editable('http://www.example.com/save.php', {
type : 'dernumber',
cancel : 'Cancel',
submit : 'OK'
});
Upvotes: 1