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
Display Text From Textbox on Enter Key Press
Nikhil Sangani
Jun 28
2016
Code
2.8
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
1.
Add jQuery on page.
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"
></script>
2.
Add HTML textarea.
<textarea id=
"txtcomment"
placeholder=
"Type your comment here and press Enter Key...."
></textarea>
3.
Add script after text area.
<script type=
"text/javascript"
>
$(
'#txtcomment'
).keypress(function (
event
) {
var keycode = (
event
.keyCode ?
event
.keyCode :
event
.which);
if
(keycode ==
'13'
) {
alert($(
'#txtcomment'
).val());
savecomment($(
'#hdnBlogid'
).val(), $(
'#txtcomment'
).val());
}
event
.stopPropagation();
});
</script>
4.
Run the html page and type in textbox when you press enter that time you can see one alert box with textbox value.
JQuery
Textbox