RequiredFieldValidator Working Oddly in Update Panel

前端 未结 1 1493
暖寄归人
暖寄归人 2021-01-23 17:17

I\'ve got an update panel with a textbox and a requiredfieldvalidator and a couple of buttons.

On pageload, you see a label and a button. On button press, the textbox a

相关标签:
1条回答
  • 2021-01-23 18:00

    Validate validators inside updatepanel on custom event.
    You can try to invoke validation on 'blur' event with jquery (or other event 'click', 'change' ,'keypress', 'keyup' etc.). For example:

     function TextBoxValidate() {
        $('input:[type="text"]:[id*="client_name"]').each(function () { $(this).on('blur', function () { var txtId = this.id; $('span').each(function () { if (this.controltovalidate == txtId) ValidatorValidate(this); }); }); }); 
    }
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(TextBoxValidate);
    

    Just add this code sample in your javascript file and include jquery library

    0 讨论(0)
提交回复
热议问题