• User Attivo

    Anche questo ultimo plugin ha solo la funzione maxlength.
    Trovo assurdo tutto questo.
    Eppure trovo milioni di form che hanno la funzionalità lunghezza minima.
    Provo a rintracciare uno di questi forum e vedere che software hanno usato.
    (Anche diggita.it per esempio ha questa funzione).


  • Super User

    Se trovi qualcosa di fatto con Wordpress e guardi nel sorgente pagina in molti casi è possibile risalire al plugin.


  • Super User

    Marta, altrimenti tagliamo la testa al toro: guardiamo il codice del tuo form ed aggiungiamo il controllo che ti manca. 😉


  • User Attivo

    @valijolie said:

    marta, altrimenti tagliamo la testa al toro: guardiamo il codice del tuo form ed aggiungiamo il controllo che ti manca 😉

    Veramente grazie a tutti per la disponibilità e gentilezza.
    😘


  • User Attivo

    Se per favore date una occhiata a questo plugin:

    wordpress.org/extend/plugins/mm-forms-community/

    Per inserire quel controllo sulla lunghezza del testo minimo.
    Oltre al fatto che ve ne sarei molto grata, è sicuramente un qualcosa utile anche per altri.
    🙂


  • User Attivo

    Dopo aver notato che nel 100% dei plugin da me testati manca il minlength per il testo di un campo (manca anche nei form html) vi invio qui la parte di validazione (sperando sia questa quella che serve) del file mmforms.php del plugin mmforms community.
    In modo che inserite quel controllo per la textarea o un altro campo, vedete voi.
    Grazie, ciao

    [PHP]function validate($contact_form) {
    $fes = $this->form_elements($contact_form['form'], false);
    $valid = true;
    $reason = array();

        foreach ($fes as $fe) {
            $type = $fe['type'];
            $name = $fe['name'];
            $values = $fe['values'];
            
            // Before validation corrections
            if (preg_match('/^(?:text|email)
    
    • ?$/', $type))
      $_POST[$name] = trim(strtr($_POST[$name], "\n", " "));

            if (preg_match('/^(?:select|checkbox|radio)
      
    • ?$/', $type)) {
      if (is_array($_POST[$name])) {
      foreach ($_POST[$name] as $key => $value) {
      if (! in_array($value, $values)) // Not in given choices.
      unset($_POST[$name][$key]);
      }
      } else {
      if (! in_array($_POST[$name], $values)) // Not in given choices.
      $_POST[$name] = '';
      }
      }

            if ('acceptance' == $type)
                $_POST[$name] = $_POST[$name] ? 1 : 0;
            
            // Required item (*)
            if (preg_match('/^(?:text|textarea|checkbox)
      
    • $/', $type)) {
      if (empty($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_required');
      }
      }

            if ('select*' == $type) {
                if (empty($_POST[$name]) ||
                        ! is_array($_POST[$name]) && '---' == $_POST[$name] ||
                        is_array($_POST[$name]) && 1 == count($_POST[$name]) && '---' == $_POST[$name][0]) {
                    $valid = false;
                    $reason[$name] = $this->message('invalid_required');
                }
            }
      
            if (preg_match('/^email
      
    • ?$/', $type)) {
      if ('*' == substr($type, -1) && empty($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_required');
      } elseif (! empty($_POST[$name]) && ! is_email($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_email');
      }
      }

            if (preg_match('/^captchar$/', $type)) {
                $captchac = '_mmf_captcha_challenge_' . $name;
                if (! $this->check_captcha($_POST[$captchac], $_POST[$name])) {
                    $valid = false;
                    $reason[$name] = $this->message('captcha_not_match');
                }
                $this->remove_captcha($_POST[$captchac]);
            }
        }
            
        return compact('valid', 'reason');
      

      }[/PHP]


  • User Attivo

    Ciao marta_de_angelis,
    puoi provare ad utilizzare il codice qui sotto:
    [php]
    function validate($contact_form) {
    $fes = $this->form_elements($contact_form['form'], false);
    $valid = true;
    $reason = array();

        foreach ($fes as $fe) {
            $type = $fe['type'];
            $name = $fe['name'];
            $values = $fe['values'];
            
            // Before validation corrections
            if (preg_match('/^(?:text|email)
    
    • ?$/', $type))
      $_POST[$name] = trim(strtr($_POST[$name], "\n", " "));

            if (preg_match('/^(?:select|checkbox|radio)
      
    • ?$/', $type)) {
      if (is_array($_POST[$name])) {
      foreach ($_POST[$name] as $key => $value) {
      if (! in_array($value, $values)) // Not in given choices.
      unset($_POST[$name][$key]);
      }
      } else {
      if (! in_array($_POST[$name], $values)) // Not in given choices.
      $_POST[$name] = '';
      }
      }

            if ('acceptance' == $type)
                $_POST[$name] = $_POST[$name] ? 1 : 0;
            
            // Required item (*)
            if (preg_match('/^(?:text|textarea|checkbox)
      
    • $/', $type)) {
      if (empty($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_required');
      }
      else{
      if ($_POST[$name]=="nome_Campo_da_Validare")
      {
      $lunghezza_minima=500; //500caratteri inclusi spazi e punteggiatura
      if(strlen($_POST[$name])<$lunghezza_minima)
      { $valid = false;
      $reason[$name] = "Il testo inserito è troppo corto";
      }
      }
      }

            if ('select*' == $type) {
                if (empty($_POST[$name]) ||
                        ! is_array($_POST[$name]) && '---' == $_POST[$name] ||
                        is_array($_POST[$name]) && 1 == count($_POST[$name]) && '---' == $_POST[$name][0]) {
                    $valid = false;
                    $reason[$name] = $this->message('invalid_required');
                }
            }
      
            if (preg_match('/^email
      
    • ?$/', $type)) {
      if ('*' == substr($type, -1) && empty($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_required');
      } elseif (! empty($_POST[$name]) && ! is_email($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_email');
      }
      }

            if (preg_match('/^captchar$/', $type)) {
                $captchac = '_mmf_captcha_challenge_' . $name;
                if (! $this->check_captcha($_POST[$captchac], $_POST[$name])) {
                    $valid = false;
                    $reason[$name] = $this->message('captcha_not_match');
                }
                $this->remove_captcha($_POST[$captchac]);
            }
        }
            
        return compact('valid', 'reason');
      

      }
      }
      [/php]Non ho testato il codice ma mi sembra possa funzionare. Puoi personalizzare [php]$lunghezza_minima[/php] a seconda della lunghezza necessaria.
      Questa riga invece [php]
      if ($_POST[$name]=="nome_Campo_da_Validare")
      [/php] va modificata sostituendo nome_Campo_da_Validare con il valore "name" dell'input type='text' o della textarea
      contenente la descrizione.
      Naturalmente questa modifica andrà replicata ogni volta che aggiornerai il plugin. 😉
      Fammi sapere se funziona tutto. 😉


  • User Attivo

    Per ora sto ricevendo

    Parse error: syntax error, unexpected T_VAR

    qui mi sembra:

    var $__form_id = 0;
    function set_formid($form_id){

            $this->__form_id =  $form_id;
            
    }
    

    Come mai?

    Grazie
    🙂


  • User Attivo

    Mi è sfuggita una parentesi graffa nel copia/incolla
    il codice è quindi:
    [php]
    function validate2($contact_form)
    {
    $fes = $this->form_elements($contact_form['form'], false);
    $valid = true;
    $reason = array();

        foreach ($fes as $fe) {
            $type = $fe['type'];
            $name = $fe['name'];
            $values = $fe['values'];
    
            // Before validation corrections
            if (preg_match('/^(?:text|email)
    
    • ?$/', $type))
      $_POST[$name] = trim(strtr($_POST[$name], "\n", " "));

            if (preg_match('/^(?:select|checkbox|radio)
      
    • ?$/', $type)) {
      if (is_array($_POST[$name])) {
      foreach ($_POST[$name] as $key => $value) {
      if (! in_array($value, $values)) // Not in given choices.
      unset($_POST[$name][$key]);
      }
      } else {
      if (! in_array($_POST[$name], $values)) // Not in given choices.
      $_POST[$name] = '';
      }
      }

            if ('acceptance' == $type)
            $_POST[$name] = $_POST[$name] ? 1 : 0;
      
            // Required item (*)
            if (preg_match('/^(?:text|textarea|checkbox)
      
    • $/', $type)) {
      if (empty($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_required');
      }
      else{
      if ($_POST[$name]=="nome_Campo_da_Validare")
      {
      $lunghezza_minima=500; //500caratteri inclusi spazi e punteggiatura
      if(strlen($_POST[$name])<$lunghezza_minima)
      { $valid = false;
      $reason[$name] = "Il testo inserito è troppo corto";
      }
      }
      }

                if ('select*' == $type) {
                    if (empty($_POST[$name]) ||
                    ! is_array($_POST[$name]) && '---' == $_POST[$name] ||
                    is_array($_POST[$name]) && 1 == count($_POST[$name]) && '---' == $_POST[$name][0]) {
                        $valid = false;
                        $reason[$name] = $this->message('invalid_required');
                    }
                }
      
                if (preg_match('/^email
      
    • ?$/', $type)) {
      if ('*' == substr($type, -1) && empty($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_required');
      } elseif (! empty($_POST[$name]) && ! is_email($_POST[$name])) {
      $valid = false;
      $reason[$name] = $this->message('invalid_email');
      }
      }

                if (preg_match('/^captchar$/', $type)) {
                    $captchac = '_mmf_captcha_challenge_' . $name;
                    if (! $this->check_captcha($_POST[$captchac], $_POST[$name])) {
                        $valid = false;
                        $reason[$name] = $this->message('captcha_not_match');
                    }
                    $this->remove_captcha($_POST[$captchac]);
                }
            }
      
            return compact('valid', 'reason');
        }
      

      }
      [/php]
      ho corretto anche il post precedente 😉


  • User Attivo

    Ho impostato così

    [PHP]if ($_POST[$name]=="your-message")[/PHP]

    Per questo form

    [PHP]<form action="/prova/#outcome_msg" method="post" class="mmf-form" enctype="multipart/form-data">
    <input type="hidden" name="_mmf" value="1" /><input type="hidden" name="_mmf_success_url" value="" />
    <input type="hidden" name="_mmf_failure_url" value="" /><input type="hidden" name="_mmf_unit_tag" value="mmf-f1-p459-o1" />
    <input type="hidden" name="page_post_id" value="459" />
    <input type="hidden" name="page_post_title" value="prova" />
    <p><label>Your Name (required)<br />
    <span class="mmf-form-control-wrap your-name"> <input type="text" name="your-name" value="" class="mmf-validates-as-required" size="40" /></span> </label></p>
    <p><label>Your Email (required)<br />
    <span class="mmf-form-control-wrap your-email"> <input type="text" name="your-email" value="" class="mmf-validates-as-email mmf-validates-as-required" size="40" /></span> </label></p>
    <p><label>Subject<br />
    <span class="mmf-form-control-wrap your-subject"> <input type="text" name="your-subject" value="" size="40" /></span> </label></p>
    <p><label>Your Message<br />
    <span class="mmf-form-control-wrap your-message"><textarea name="your-message" cols="40" rows="10"></textarea></span> </label></p>
    <p><input type="submit" value="Send" /> <img class="ajax-loader" style="visibility: hidden;" alt="ajax loader" src="nomedominio/wp-content/plugins/mm-forms-community/images/ajax-loader.gif" /></p>
    </form>[/PHP]

    Ma purtroppo non funziona. Non da errore ma non funziona e non arriva l'email dei dati del form.