views:

369

answers:

4

I have an ASP.NET page with a jQuery dialog that is displayed to change some data. I am setting up the jQuery dialog so that when the user clicks the OK button it calls ASP.NET's

Page_ClientValidate('validationGroup') via javascript, finds all the invalid controls and changes their CSS class. So here's the scenario: the user opens the dialog, keys in some invalid data, clicks OK (receiving the validation messages), and then clicks Cancel.

Now the dialog is closed, but the validation messages are still there, so that when they open the dialog again, the data goes back to the way it was initially, but the form is still in the invalid state (the validation messages are still displaying).

What I need is a "reset" function of sorts to call after calling Page_ClientValidate('validationGroup'). Does this exist?

A: 

Why don't you just remove validation messages when user clicks cancel?

epitka
I suppose I could, but it seems like there should be a reset function. If I was to remove the messages when the user clicks cancel, I would have to add them back when I wanted to validate again, and that's more involoved than I wanted to get. I guess at this point, that is my fallback solution, though.
Josh Young
+1  A: 

Why don't you put the a from around the inputs in your dialog and use a reset button for cancel

<input type="reset" value="Cancel" />

Edit:

if your dialog control are already reset, re-validate when opening the dialog.

MK
Thanks for your help.
Josh Young
+1  A: 

You can call the client-side function ValidatorValidate(validatorObj) to force validation to trigger again upon a specific validator. If you're resetting (clearing) the form values to what the validators are expecting as defaults, then triggering the ValidatorValidate function on them, you should be okay. See documentation here.

Nicholas H
Thanks for your help, Nicholas. It is much appreciated.
Josh Young
A: 

Hi Josh,

I am also facing the same issue in reset the validation.Did you find any solution? Please share with me.

Thanks Bagi

Bagi