Here's a quick example on how to display a warning icon inside a TextBox when validation fails.
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<style type="text/css">
.warning{
background: url(warning.png) no-repeat;
padding-left: 18px;
border:1px solid #ccc;
}
</style>
<script>
$(function () {
$("#txt").keypress(function (e) {
//if the letter is not digit then display error and don't type anything
if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
//attach css
$("#txt").addClass("warning");
$("#txt").val("");
return false;
}
else{
$("#txt").removeClass("warning")
}
});
});
</script>
</head>
<body>
<input type = "text" id="txt"/>
</body>You can see the actual demo here: http://jsfiddle.net/xoh7jm3c/10/