We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13460
    • 47 Posts
    Quote from: TheWebScientist at May 31, 2011, 02:05 PM

    Yeah, both the placeholder and the javascript wouldnt be a good solution. Since javascript won’t work in the Lynx browser

    It also isn’t supported with carrier pigeons grin grin Putting the error as a value in the input-element should not require javascript.
      UI /UX designer + bit of Front-End Developer. Getting around with MODx Revolution
      • 7976
      • 36 Posts
      haha grin good one. But sorry I mis-understood you.

      Also clearing the error message from the value attribute does require javascript?
      Anyway if you do want to put this in the value then try this:
      <input type="text" name="naam" id="naam" value="[[!+fi.error.naam:notempty=`[[!+fi.naam:lte=`5`:then=`There are less than 5 books`:else=`There are more than 5 books`]]`]]" class="required">
        Jack of all Trades and Proud Honda Zoomer owner. Also available on twitter.
        • 13460
        • 47 Posts
        Why?! Correct me if I’m wrong but when the post is handled by FormIt it could inject the error-message in the value="[[+fi.error]] else [[+fi.something]]" I’ve got another topic about my idea. drop a piece of the code here;

        placeholder="[[!+fi.error.contact_subject:equalto=``:then=`your subject here`]]" tabindex="3" value="[[!+fi.error.contact_subject:equalto=``:then=`[[!+fi.contact_subject]]`:else=`[[!+fi.error.contact_subject:notags]]`]]"
        Tried it with :notempty but, actually different subject, doesn’t work. My idea is there but probably not the most smart/ advanced way.
          UI /UX designer + bit of Front-End Developer. Getting around with MODx Revolution
          • 7976
          • 36 Posts
          I see ur problem now, try this:
          placeholder="[[!+fi.contact_subject:ifempty=`your subject here`]]"

          value="[[!+fi.error.contact_subject:ifempty=`[[!+fi.contact_subject]]`:else=`[[!+fi.error.contact_subject]]`]]"
            Jack of all Trades and Proud Honda Zoomer owner. Also available on twitter.
            • 19328
            • 433 Posts
            Hi Webscientist,

            Does your snippet ’FormItValidator’ also work with the math hook?
            I have tried it, and this is what happens. I do get an error message if the math question is not answered at all (left empty) (it is a required field). But if the question is answered wrong, no error message is displayed.

            When I place [[!+fi.error.math]] on the page, this does give an error message.
            But the formitvalidator snippet just displays the intro text, as if nothing is wrong.
            For other fields, like e-mail and name, it does work properly. (it also displays an error if a non-valid email address is filled in).

            Thanks for any help,
            Michelle
              • 7976
              • 36 Posts
              Hi Michelle,

              My snippet depends on the build-in FormIt validators.
              Sadly the Math hook does not throw an error within this validator and therefor I cannot read the occured error within $validator. (see custom validators)

              This might be bug but to honest I have no time on my hands to report it or to make a custom snippet to solve this problem.
              If FormIt would throw an error within its validator it would be very easy to extend my codes and to add your own error message.

              Wish I could help you more,
              ~TheWebScientist
                Jack of all Trades and Proud Honda Zoomer owner. Also available on twitter.
                • 19328
                • 433 Posts
                Hi TheWebScientist,

                Thanks for your reply. At least I now know I’m not doing anything wrong ;-).
                For now I’ve solved the problem by not using the math hook at all, I just let the user fill in the answer to a fixed math question and check that field. This works for now.

                Besides this your snippet is great! Thanks for creating it smiley.

                Michelle
                  • 7976
                  • 36 Posts
                  You’re welcome. I had to double check if my snippet wasnt doing anything wrong too :-D
                  I will add this ’problem’ to my todo list to find a workaround or I hope splittingred could give me another insight.

                  Also thank you for your compliment! If you have any improvements I can add to my todo then please let me know!

                  ~TheWebScientist
                    Jack of all Trades and Proud Honda Zoomer owner. Also available on twitter.
                    • 7976
                    • 36 Posts
                    This custom validator is deprecated since FormIt 1.5.1.

                    Use:
                    [[!+fi.validation_error_message]]

                    And:
                    &validationErrorMessage=`<p>A form validation error occurred: [[+errors]]</p>`
                      Jack of all Trades and Proud Honda Zoomer owner. Also available on twitter.