Click here to Skip to main content
15,891,868 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I have to display a error message in a div if the textbox is empty.
But same time after 5 sec. I have hide the same error message div.
Can any one help me out.

C#
$('#button').click(function () {

var txt= $("#txt_box1").val();
    if (txt== "") {
       $("#txt").css({ 'border': '1px solid #f2d3ce' });
//div ID error_msg
       $("#error_msg").show(slow);
            hidemeplease();
      }
});

function hidemeplease(){
//how to write the code for hiding the div after 5sec.
}
Posted

You can use setTimeout function in jquery to hide the div after 5 seconds or so.
JavaScript
setTimeout(function() {
        $div2.hide();
    }, 5000);
 
Share this answer
 
v2
Comments
Arunprasath Natarajan 21-Sep-13 6:25am    
Tan q it works.
this will help you..

C#
$(document).ready(function(){
   setTimeout(function(){
      $("#popupBox").fadeOut("slow") //#popupBox is the DIV to fade out
   }, 5000); //5000 equals 5 seconds
});


for More visit here..

http://www.jquery4u.com/jquery-functions/settimeout-example/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900