ASP.NET: checking "reset" after calling Page_ClientValidate

I have an ASP.NET page with a jQuery dialog that appears to modify some data. I configure the jQuery dialog so that when the user clicks OK, he calls ASP.NET

Page_ClientValidate('validationGroup')through javascript, finds all invalid controls and modifies their CSS class. So, here is the scenario: the user opens a dialog, keys in some invalid data, clicks OK (receiving verification messages), and then clicks Cancel.

Now the dialog is closed, but the validation messages still exist, so when they open the dialog again, the data returns to its original state, but the form is still in an invalid state (validation messages are still displayed).

I need a "reset" function to call after the call Page_ClientValidate('validationGroup'). Does it exist?

+3
source share
4 answers

You can call the client function ValidatorValidate(validatorObj)to force the validation for a specific validator. If you reset (clear) the values โ€‹โ€‹of the form to what the validators expect as default values, then calling the function ValidatorValidateon them, you should be fine. See here .

+1
source

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

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

Edit

if your dialog control is already reset, retest when opening the dialog.

+2
  • , validator1, validator2 ..

  • javascript, :

    var n = 0;
    var z = '';
    
    for (var i = 0; i < Page_Validators.length; i++) {
        n += 1;
        z = 'ctl00_MainContent_validator' + n;
        document.getElementById(z).style.visibility = 'hidden';
    }
    

    .

  • , , .

Voila.

+1

?

0

Source: https://habr.com/ru/post/1728342/


All Articles