|
Post by Admin on Aug 27, 2015 11:47:31 GMT
Sometime I faced, after hitting enter key page is automatically being submitted. That is due to define form is hitting submit event after pressed enter key. Mainly this thing found when you press enter on single line Textbox.
Add the following java script code in you page and look the magic.
$(document).ready(function () { $(window).keydown(function (event) { if (event.keyCode == 13) { event.preventDefault(); return false; } }); });
|
|
|
Post by Admin on Aug 27, 2015 14:00:53 GMT
Now I am facing another problem. I have some textarea means multiline textbox. Now it is not accepting return key. So I can't add new line.
After a little bit finding I change a little bit into that function as follows.
$(document).ready(function () { $("input").keydown(function (event) { if (event.keyCode == 13) { event.preventDefault(); return false; } }); });
As I have to protect only all inputs to react against return hit, it works perfectly.
|
|