I have attached a keypress event to my textbox. when the user presses other keys i am doing some processing work, but when the user presses the Enter key i am submitting the value in the textbox to some server. I am able to do all processing and every thing is fine, but when i press enter key the event is not getting fired. so, i ma unable to submit my value to the server.
Here is my code:
$("#txt" + filterID).keypress(txtInput_keypress);
function txtInput_keypress(e) {
var code = (e.keyCode ? e.keyCode : e.which);
var strValue = $(this).val()+ String.fromCharCode(e.which);
var bool = $.trim(strValue).match(reg);
if (code == 13) {
//textbox value submission code
}
else if (parseFloat($.trim(strValue)) > max) {
e.preventDefault();
}
else if (bool) {
return true;
}
else {
e.preventDefault();
}
}
whats wrong with my code? Please somebody help me to fix this issue.
1 Answer