<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>Here you can check that Textbox value is empty or null using JQuery.
