Search code examples
validationcheckboxmodalpopupextender

ModalPopUpExtender with checkbox validation


I have an AJAX Application that I have been working on. At this point in the development - I have a modalpopupextender with a warning message and an OK and Cancel button. I have just been tasked with changing this to be three checkboxes and having the OK button disabled until all three boxes have been checked. I'm having a difficult time trying to accomplish this. I'm not sure if I should use a checkboxlist control or just three checkboxes. I am also not sure if the enabling/disabling of the button should be handled through javascript or codebehind. I have tried a little of both - with no success so any guidance is very much appreciated.


Solution

  • Three checkboxs would seem to work quite well if you ask me.. you can have each check box run the same validation function to check on the other 2. Also, i have found that using 'this.disable=true' would work quite well for what you are trying to accomplish. This way everything is handled under JS and there is no need to use the codebehind.

    function validate() {
        if ('checkbox is not checked')
            return;
        if ('checkbox2 is not checked')
            return;
        if ('checkbox3 is not checked')
            return;  
        submit.disabled = false;
    }