Coder1010
Coder1010

Reputation: 29

How to validate whether a user enters something into a textbox while leaving it?

What I have is a simple form.My problem is that I have validated it through Javascript on click of Submit button.What if I want to validate as soon as the user presses TAB key and goes to next field without filling in the first?I have called the Javascript function on OnFocusOut event of textbox but it disables all my other links on the page(If I don't want to remain on that page and navigate to some other).Kindly help....

Upvotes: 0

Views: 4390

Answers (1)

Ashish Babu
Ashish Babu

Reputation: 1175

$(document).ready(function(){
$("#txtName").focusout(function(){
if($("#txtName").val()=="")
{
alert("enter text");
}
});
});

Upvotes: 1

Related Questions