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

    Is it possible to have the validation messages displayed without reloaded the page? I have a form at the bottom of a long page so when the form fails validation it is slightly confusing for the user as they can’t see the error unless they scroll down the page. Failing that, does any know any other ways of getting around this little problem?

    G
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The only way to do that is to use a javascript validation script. There are a number of them freely available; Google is the best way to find a bunch of them. I’ve used several, and can’t really specifically recommend any one of them. They all pretty much do the job.
        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
        • 23491 ☆ A M B ☆
        • 1,056 Posts
        Quote from: sottwell at Apr 20, 2007, 01:29 AM

        The only way to do that is to use a javascript validation script. There are a number of them freely available; Google is the best way to find a bunch of them. I’ve used several, and can’t really specifically recommend any one of them. They all pretty much do the job.

        Here is one that I haven’t tried yet, but I believe it uses MooTools v1.0 smiley

        http://www.phatfusion.net/formvalidation/

        I likely will make a switch to this one should it test out ok, as others I have tried continually conflict with QuickEdit, Moo, and others (as some require prototype and scriptaculous)

        NOTE: During a quick review of the validate.js file from the demo page, I noticed this code:

        if(!valid){
            this.messageBox.setStyle('display','block');
            document.location = '#'+this.formAnchor.name;
        


        ...If you happen to be using <base href=""> in your MODx sites (I personally always do), then this piece of code my not function as intended:
        document.location = '#'+this.formAnchor.name; 
        

        it might need to be updated to the following (for base href usage) or commented out altogether.
        document.location = document.location.href+'#'+this.formAnchor.name;
        
          Mike Reid - www.pixelchutes.com
          MODx Ambassador / Contributor
          [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
          ________________________________
          Where every pixel matters.
          • 10357
          • 573 Posts
          thanks for the tips grin

          I actually used the template switcher to do a nice little trick to get round this problem.


          G
            • 30223
            • 1,010 Posts
            If your only problem is that you have to scroll down to see the error message there is a simpler solution... Just place the [+validationmessage+] place holder somewhere near the top in your document instead of in the form template!
              • 10357
              • 573 Posts
              Hi,

              I did try to put [+validationmessage+] at the top of my template (outside the form) but it did not work.


              G.
                • 30223
                • 1,010 Posts
                Hmm, perhaps you still have the [+validationmessage+] in your form template as well? If so, delete it from the form template. eForm tries the form template first and only if it finds no place holder will it try to set it’s value using the modx api (which means it could be anywhere, in the document or in the template...).
                  • 10357
                  • 573 Posts
                  nope.. I did not leave it in my form template.