how to a make label message disable after 10 seconds
I have a form with two text boxes. Once I enter the data and click the save button, I get a message in label: indicating that it saved successfully.
Then i am in the same form again, but when I click on the save button, I get a message telling me that it cannot be blank "as textbox value is empty this time" from开发者_如何学运维 the required field validator.
But I am still showing the message "data saved successfully," which should not happen. is there any way can after showing the message: data saved sucessfully. after 10 seconds. i can hide the label. are clear the value in tha label. sothati snt show the message How do I solve this issue?
Thank you.
setTimeout("function_to_hide_label()", time_in_milliseconds);
Time is "after how much time the function should be called".
Edit:
$('#btnSave').click(function() {
$('#lblsuccess').show();
setTimeout(function(){ $('#lblsuccess').hide(); }, 10000);
});
Something like this should probably work, I didn't test it though.
You can use a timout in Javascript or maybe the timer plugin from jQuery. This will allow you to create a function that removes teh message after a period of time. I haven't used the timer plugin myself but it seems pretty stable.
$("#save-button").click(function() {
//code to save etc
$("your label").oneTime(10000, "hide", function() {
$("Your Label").hide();
});
});
Try the jQuery timer plugin. You can do something like this:
$('#your-label').oneTime(10000, function() {
$(this).hide();
});
You should change your validation function to clear the message when it runs. This way when the user tries to resubmit the form, the data message goes away at that time. Making it disappear after 10 seconds will feel strange if the form is resubmitted within 10 seconds.
精彩评论