We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46886
    • 1,154 Posts
    I just noticed that the error messages in my register snippet don't work at all. I especially need some of them so new users know what the problem is.

    When I try to make a new user with an existing username, it just refreshes sort of, and all data is gone. No error pops up, so my users don't know what went wrong.

    The snippet and form themselves work fine, why no error message? I specifically remember before seeing the error message...

    I wonder if it could have anything to do with the avatar upload I put in here. Anyway, here is my snippet and form:

    [[!Register?
        &submitVar=`registerbtn`   
        &preHooks=`formatDob`
        &activationEmailTpl=`myActivationEmailTpl`
        &activationEmailSubject=`Please activate your account in Test Forum!`
        &activationResourceId=`9`
        &submittedResourceId=`13`
        &usergroups=`19`
        &useExtended=`1` 
        &excludeExtended=`email:required:email,login-updprof-btn`
        &validate=`nospam:blank,
      username:required:minLength=^6^,
      password:required:minLength=^6^,
      password_confirm:password_confirm=^password^,
      fullname:required,
      email:required:email,
      date_of_birth:required,
        &placeholderPrefix=`reg.`
    ]]
    <h1>Register</h1>
    <legend class="loginFPLegend">Required Fields</legend>
    <div class="register">
        <div class="registerMessage">[[!+reg.error.message]]</div>
            
        <form class="form" enctype="multipart/form-data" action="[[~[[*id]]]]" method="post">
            <input type="hidden" name="nospam" value="[[!+reg.nospam]]" />
            <!--Username-->
    <li style="border-bottom:1px dashed #7e7e7e;"><label for="username">[[%register.username? &namespace=`login` &topic=`register`]]
                <span class="error">[[!+reg.error.username]]</span>
            </label>
            <input type="text" name="username" id="username" value="[[!+reg.username]]" />
    <p class="note">Minimum 6 characters, and at least one letter.</p></li>
            <!--Fullname-->
            <br class="clear" />
    <li style="border-bottom:1px dashed #7e7e7e;"><label for="fullname">[[%register.fullname]]
                <span class="error">[[!+reg.error.fullname]]</span>
            </label>
            <input type="text" name="fullname" id="fullname" value="[[!+reg.fullname]]" />
    <p class="note">Whatever name you prefer. In the forums you may use a display name as well.</p></li>
            <br class="clear" />        
    <!--Password-->
    <li style="border-bottom:1px dashed #7e7e7e;"><label for="password">[[%register.password]]
                <span class="error">[[!+reg.error.password]]</span>
            </label>
            <input type="password" name="password" id="password" value="[[!+reg.password]]" />
         
            <label for="password_confirm"> Confirm
                <span class="error">[[!+reg.error.password_confirm]]</span>
            </label>
            <input type="password" name="password_confirm" id="password_confirm" value="[[!+reg.password_confirm]]" />
    <p class="note">Minimum 6 characters.</p></li>
            <!--Email-->
            <br class="clear" />  
    <li style="border-bottom:1px dashed #7e7e7e;"><label for="email">[[%register.email]]
                <span class="error">[[!+reg.error.email]]</span>
            </label>
           <input type="text" name="email" id="email" value="[[!+reg.email]]" />
    <p class="note">Must be a valid email.</p></li>
            <br class="clear" />
            <!--Date of birth If you want it in the User General Information field than "date_of_birth" must be replaced with "dob"-->
    <li style="border-bottom:1px dashed #7e7e7e;"><label for="date_of_birth">Date of Birth:</label>
                <span class="error">[[!+reg.error.date_of_birth]]</span>
            </label>
            <input type="text" name="date_of_birth" id="dob" value="[[!+date_of_birth:date=`%Y-%m-%d`]]" />
    <p class="note"><b>Must</b> be in the form YYYY-MM-DD! DoB is only for verification purposes.</p></li>
            <br class="clear" />
            <div class="form-buttons">
                <input type="submit" name="registerbtn" value="Register" />
            </div>
            <br class="clear" />
        </form>
    </div>

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

    • discuss.answer
      • 46886
      • 1,154 Posts
      Well this took me forever to figure out.

      &validate=`nospam:blank,
      username:required:minLength=^6^,
      password:required:minLength=^6^,
      password_confirm:password_confirm=^password^,
      fullname:required,
      email:required:email,
      date_of_birth:required,`
      &placeholderPrefix=`reg.`

      Missing the backtick at the end of the &validate argument...so simple yet hard to find...
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Yes, I still do that all the time with FormIt - no comma on the last one, but a backtick on the last one!
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 46886
          • 1,154 Posts
          Ha yeah its a weird rule, I must remember it. no comma on last, but a backtick.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            It's not weird at all, it's how properties work.

            The entire &valdiate bit is one property, so it must be enclosed in backticks, just like any other property's value.

            And the validation rules are a comma-separated list, but the last one can't have a comma, since there isn't one after it. Javascript works the same way, some browsers will forgive a trailing comma, some will throw an error.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 46886
              • 1,154 Posts
              Yes, its logical, just hard to see when there is a mistake. Shouldn't be that hard, but I looked over this one carefully at first and missed it.