简体   繁体   中英

Can I reset the validation for a Required Field Validator in a Javascript function?

-I have an aspx page that has several required field validators.

-After the user clicks on the save button and the page fails the validation you can no longer do anything on the page except fill in the fields.

-Three of the fields are disabled and are filled by clicking on a button that runs a javascript function that opens a popup where the user chooses a person and return the id of the person. The javascript function triggers a server side event that fills the fields.

The problem is that the trigger is never fired because the page is invalid.

Is there any way to reset the validation when the user clicks on the button?

-The javascript function does fire and open the popup but the trigger on the page that is failed will not work.

Things I have already tried:

  1. do a postback in the javascript function - page does not post back
  2. CausesValidation="false" - does not work
  3. Page_BlockSubmit = false - no effect
  4. Page_IsValid = true - no effect
    The javascript function is as follows:

     function OpenStudentPopup(pDistrictId) { var modal = PopupContainer.createPopup('modal'); var pc = new PopupContainer(modal, { src: '/pages/popup/SearchPerson.aspx?id=' + pDistrictId, showConfirmationWhenClosing: true, close: function (pData) { $("#hdnChild").val(pData); var sse = new ServerSideEvent('tgrChild'); sse.fire(); } }); } 

Finally found the answer. In my Javascript function I added the following code: Page_ValidationActive = false; This allows the trigger to be fired and resets the entire page until a user tries to save again. //New Javascript function

function OpenStudentPopup(pDistrictId) {
        Page_ValidationActive = false; //This resets the validation
        var modal = PopupContainer.createPopup('modal');
        var pc = new PopupContainer(modal, {
            src: '/pages/popup/SearchPerson.aspx?id=' + pDistrictId,
            showConfirmationWhenClosing: true,
            close: function (pData) {
                //if (pData == true) {
                $("#hdnChild").val(pData);
                var sse = new ServerSideEvent('tgrChild');
                sse.fire();  
                //}
            }

        });
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM