We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36565
    • 73 Posts
    Hey guys,

    is it possible to use a FormIt validator to execute some JS to, say, unhide an edit box as a response to an invalidly filled field, while staying on the page?
    So far, I have been trying things like
      $erfolg = (!in_array($value,$filledDrawers));
      if (!$erfolg) {
        echo '<script type="text/javascript">showdiv("editArchivNr");hidediv("CD-Table");</script>';
        $validator->addError($key,'Archivnummer ist schon belegt!');
      }
      return $erfolg;
    

    That fails, the JS is ignored and the page is reloaded.

    In case what I write is understandable, Is there any way to achieve what I'm aiming at?

    Thanks! [ed. note: neo2.0 last edited this post 11 years, 7 months ago.]
      PHP illiterate MODx enthusiast
      • 16348
      • 64 Posts
      You should be able to use the error message for the field to insert a
      style="display:none"
      attribute in the right place, or to output your JS.