TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Don't Refresh the Page When I Press Enter into TextBox
Sushant Kesari
Nov 26
2015
Code
1.5
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<script language=
"JavaScript"
><!--
var
nav = window.Event ?
true
:
false
;
if
(nav) {
window.captureEvents(Event.KEYDOWN);
window.onkeydown = NetscapeEventHandler_KeyDown;
}
else
{
document.onkeydown = MicrosoftEventHandler_KeyDown;
}
function
NetscapeEventHandler_KeyDown(e) {
if
(e.which == 13 && e.target.type !=
'textarea'
&& e.target.type !=
'submit'
) {
return
false
; }
return
true
;
}
function
MicrosoftEventHandler_KeyDown() {
if
(event.keyCode == 13 && event.srcElement.type !=
'textarea'
&& event.srcElement.type !=
'submit'
)
return
false
;
return
true
;
}
//
--></script>
prevent auto refresh page
JQuery