We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31338
    • 30 Posts
    I am using FormIT everything is working fine except I want to be to add a validation email field, i.e they enter their email address and then have to re enter their email address and the second filed checks it matches the first field.


    <li>
        <label for="email">
            Email:*
            <span class="error">[[+fi.error.email]]</span>
        </label>
        <input type="text" name="email:email:required" id="email" value="[[+fi.email]]" />
    </li>
    
    
    <li>
    <label for="checkemail">
            Re Enter Email:*
            <span class="error">[[+fi.error.checkemail]]</span>
        </label>
        <input type="text" name="checkemail:contains="[[+fi.email]]" id="checkemail" value="[[+fi.checkemail]]" />
    </li>


    The section name="checkemail:contains="[[+fi.email]]" I have changed to various different formats but i cant get it to work.
      Use our Free Developers API and build SMS in to your customers website or store or application. http://www.VibeActiveMedia.com
      • 40045
      • 534 Posts
      According to http://rtfm.modx.com/display/ADDON/FormIt.Validators

      I would just try to abuse the password_confirm validator to check the emails =)...and if this doesn't work, I would steal that validator code and make a custom one for email out of it...
        • 31338
        • 30 Posts
        Ok i tried that, i took the password code and duplicated it and changed it with email2 and email_confirmation instead of password2 and password_confirmation

        I can only find 2 pages that i needed to change a couple of entries in, is there anywhere else i need to look.

        formit/model/formit/fivalidator.class
        formit/lexicon/en/default.inc

          Use our Free Developers API and build SMS in to your customers website or store or application. http://www.VibeActiveMedia.com
          • 38878
          • 255 Posts
          Can you post your Formit snippet call?

          Quote from: vbTrev at Jan 26, 2013, 09:52 PM
          Ok i tried that, i took the password code and duplicated it and changed it with email2 and email_confirmation instead of password2 and password_confirmation

          I can only find 2 pages that i needed to change a couple of entries in, is there anywhere else i need to look.

          formit/model/formit/fivalidator.class
          formit/lexicon/en/default.inc

            • 31338
            • 30 Posts
            Here is the part in the form:

            <li>
                <label for="email">
                    Email:*
                    <span class="error">[[+fi.error.email]]</span>
                </label>
                <input type="text" name="email:email:required" id="email" value="[[+fi.email]]" />
            </li>
            
            
            <li>
            
            <label for="email2">
                    Re Enter Email:*
                    <span class="error">[[+fi.error.email2]]</span>
                </label>
                <input type="text" name="email2:email_confirm=`email` id="email2" value="[[+fi.email2]]" />
            </li>


            here is the code from the files:

            This is exactly the same as the password part, except i changed the word password to email:
            public function email_confirm($key,$value,$param = 'email_confirm') {
                    if (empty($value)) return $this->modx->lexicon('formit.email_not_confirmed');
                    if ($this->fields[$param] != $value) {
                        return $this->_getErrorMessage($key,'vTextEmailConfirm','formit.email_dont_match',array(
                            'field' => $key,
                            'email' => $value,
                            'email_confirm' => $this->fields[$param],
                        ));
                    }
                    return true;
                }
            	
            	
              Use our Free Developers API and build SMS in to your customers website or store or application. http://www.VibeActiveMedia.com
              • 40045
              • 534 Posts
              Does it work or do you get some (or none) output that is not desired?
                • 31338
                • 30 Posts
                I get nothing, if i put the &validate email2 in the [[!FormIt? section when i try and submit the form it says that i need to enter something, so i copy the email address into and re click submit but it still thinks there is nothing in the field.

                  Use our Free Developers API and build SMS in to your customers website or store or application. http://www.VibeActiveMedia.com
                  • 40045
                  • 534 Posts
                  Did you check if the field is in the post data array? (Firebug FTW)

                  Just curious bc I see this the first time: Does validation actually work when put into the name attributes? I always add them into the &validate=`` param of the snippet itself... =)?