We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36573
    • 173 Posts
    On the form the user inputs a 3 letter answer and if that answer equals either code or altcode (answer in a TV) then redirect. I've tried a number of options this is just the latest that is not working.


    [[!FormIt?
    &submitVar=`answ`
       &hooks=`redirect`
       &redirectTo=`[[+page]]`
    
    &validate=`
       answ:contains=^[[+altcode]]:or:[[+code]]^`
    ]]
    


    Thanks for any help.

    This question has been answered by Bruno17. See the first response.

      Everything I know I learned on the internet. Saved me thousands in College tuition,
      • 4172
      • 5,888 Posts
      I think, you will need a custom validator something like that:

      <?php
      /*
       & customValidators=`containsOneOfThem`
       & validate=`message:containsOneOfThem=^Hello,Dear,Hi,Hey^`
      */
      
      $params = explode(',',$param);
      $success = false;
      
      foreach ($params as $param){
          if (strstr($value,$param)){
              $success = true;        
          }
      }
      
      if (!$success) {
        // Note how we can add an error to the field here.
        $validator->addError($key,'one or more words are missing');
      }
      return $success;
      ?>
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • discuss.answer
        • 4172
        • 5,888 Posts
        Or:

        <?php
        /*
         & customValidators=`equalsOneOfThem`
         & validate=`color:equalsOneOfThem=^red,green,blue^`
        */
         
        $params = explode(',',$param);
        $success = false;
         
        foreach ($params as $param){
            if ($value==$param){
                $success = true;       
            }
        }
         
        if (!$success) {
          // Note how we can add an error to the field here.
          $validator->addError($key,'one or more words are missing');
        }
        return $success;
        ?>
        
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 36573
          • 173 Posts
          That did it. Thanks. I really need to learn more PHP.

          Quote from: Bruno17 at Apr 13, 2014, 05:45 AM
          Or:

          <!--?php
          /*
           & customValidators=`equalsOneOfThem`
           & validate=`color:equalsOneOfThem=^red,green,blue^`
          */
           
          $params = explode(',',$param);
          $success = false;
           
          foreach ($params as $param){
              if ($value==$param){
                  $success = true;       
              }
          }
           
          if (!$success) {
            // Note how we can add an error to the field here.
            $validator--->addError($key,'one or more words are missing');
          }
          return $success;
          ?>
          
            Everything I know I learned on the internet. Saved me thousands in College tuition,