Try this:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
#errormsg
{
color:red;
display: none;
}
</style>
<script>
$(document).ready(function(){
$("input").blur(function(){
if ($(this).val() == ""){
$(this).next().show();
} else {
$(this).next().hide();
}
});
});
</script>
</head>
<body>
<div>
Email:
<input type="text" name="email" id="txtEmail">
<label id="errormsg">Enter Email</label>
</div>
<div>
Name:
<input type="text" name="name" id="txtName">
<label id="errormsg">Enter Name</label>
</div>
</body>
</html>
Up front, set the respective erormsgs. then hide them through the css using display:none. On blur event, when the input value is empty, then show the errormsg else hide it through jQuery. You have to read out the jquery selector to understand it better:
jquery_ref_selectors[
^]