2 Replies Latest reply on Aug 31, 2012 1:46 PM by frameexpert

    Validate dialog on OK button or Enter key

    frameexpert Level 4

      I have a dialog with a bunch of checkboxes and OK and Cancel buttons. When the user clicks OK or presses Enter, I want to validate the other controls and keep the dialog open if none of the checkboxes are checked. I know how to test the checkboxes, but I am not sure how to do this with an event handler and keep the dialog open. Any suggestions or pointers would be appreciated.

       

      Rick

        • 1. Re: Validate dialog on OK button or Enter key
          CarlosCanto Adobe Community Professional & MVP

          here is one way of doing it

           

          var w = new Window('dialog');
          var chk1 = w.add('checkbox', undefined, 'check 1');
          var chk2 = w.add('checkbox', undefined, 'check 2');
          
          
          var btnOk = w.add('button', undefined, 'ok');
          var btnCancel = w.add('button', undefined, 'cancel');
          
          
          btnOk.onClick = function () {
                    //alert('click');
                    checked ();
          }
          
          
          
          
          btnCancel.onClick = function () {
                    //alert('cancel');
                    checked ();
          }
          
          
          
          
          w.show();
          
          
          function checked () {
                    if (chk1.value || chk2.value)
                                        alert('checked');
                    else
                              alert('unchecked');
          }
          
          • 2. Re: Validate dialog on OK button or Enter key
            frameexpert Level 4

            Excellent, Carlos. Thanks!

             

            Rick