I am using an editable HTML file located on my asp.net webpage. It looks like this, 
How to add validation in the Target column to get only float values?
Function (to enable editing):
function editRow(oTable, nRow) { var aData = oTable.fnGetData(nRow); var jqTds = $('>td', nRow); jqTds[0].innerHTML = aData[0]; jqTds[1].innerHTML = aData[1]; jqTds[2].innerHTML = '<input type="text" id="Float" class="form-control" value="' + aData[2] + '">'; jqTds[3].innerHTML = '<a class="save-row" href="">Save</a>'; jqTds[4].innerHTML = '<a class="cancel-row" href="">Cancel</a>'; }
I tried adding a keypress event to the text box, but its not working.!
$('#Float').keypress(function (event) { if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57) && (event.which != 8)) { event.preventDefault(); } });
I'm new to jquery, so please help me solve this problem?
source share