C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
JQuery Check Textbox Value is Empty or Null
WhatsApp
Mukesh Kumar
Oct 03
2015
94.2
k
0
1
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<title>jQuery Check
if
string
empty or
null
</title>
<script type=
"text/javascript"
src=
"http://code.jquery.com/jquery-1.8.2.js"
></script>
<script type=
"text/javascript"
>
$(function() {
$(
'#btnCheck'
).click(function() {
var txt = $(
'#txtName'
);
if
(txt.val() !=
null
&& txt.val() !=
''
) {
alert(
'you entered text '
+ txt.val())
}
else
{
alert(
'Please enter text'
)
}
})
});
</script>
</head>
<body>
<div>
Enter Text:
<input type=
"text"
id=
"txtName"
/>
<input type=
"button"
id=
"btnCheck"
value=
"Check"
/>
</div>
</body>
</html>
jquery
Textbox
Check Textbox Value using JQuery
Up Next
JQuery Check Textbox Value is Empty or Null