SUPPORT THE SITE WITH A CLICK

Subscribe Rss:

SUPPORT THE SITE WITH A CLICK

Saturday, January 26, 2013

Jquery submission of values on keypress

This was a interview question, where i was asked to create a todo application with any JavaScript framework.



Requirement was to add the daily task and the code shouldn't have any form and submit button.Also the task to be added with the enter key press.

On searching found couple of articles one about the prevention of form on enter key press and other from stackoverflow submitting a form on 'Enter' with jQuery?

Then i come up with my code.

JS Code


$('input').bind("keypress",function (e) {
if (e.which == 13) {
/**Append Logic **/
e.preventDefault();
}
});



JSFiddle

No comments :

Post a Comment