views:

129

answers:

4

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.

A: 

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();
         });
});
Vincent Ramdhanie
+2  A: 
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.

Soufiane Hassou
my label id:lblsuccess , my button id: btnSave so would you plz give the entire coding how to to do it
prince23
I edited my answer with a new code.
Soufiane Hassou
Just a little note, `setTimeout("function_to_hide_label()", time_in_milliseconds);` can be written as `setTimeout(function_to_hide_label, time_in_milliseconds);`, no implicit eval, just a plain old function.
nlogax
A: 

Try the jQuery timer plugin. You can do something like this:

$('#your-label').oneTime(10000, function() {
    $(this).hide();
});
Sam Soffes
hi. how to call this function . on button click event should i call this functinor how should i be calling this function
prince23
A: 

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.

Byron Whitlock