We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33372
    • 1,611 Posts
    Hello -

    I have a select menu whose options are created via JavaScript when another select menu is changed (choose a continent and the list of countries is created). I haven’t been able to get the latest eForm to allow me to submitthis form at all (it always returns an error that the value is invalid). I tried adding eform="::0::" and eform_options="::0::" and even using #EVAL return true;, but nothing I did made a difference (so I ended up just commenting out all select menu validation in the snippet file itself).

    Is there a way to bypass this validation for select fields (and I assume checkboxes and radio buttons as well)?

    Serves me right for making a form that depends on JavaScript I guess...


    ZAP
      "Things are not what they appear to be; nor are they otherwise." - Buddha

      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
      • 30223
      • 1,010 Posts
      Hmm, eForm isn’t particularly suited to javascript generated form elements. The whole purpose of the inbuilt validation is to make forms as easy and secure as possible. Unfortunately this pre-packaged functionality works against you In your case sad

      Having said that,....
      Usually the parser ’reads’ the option tags for select fields and sets the validation accordingly. However when you set a custom validation rule the custom validation should take precedence, so in principal what you did with the #EVAL return true; should work. Can you set &DEBUG=`1` and copy the debug messages here? When you submit the form it should printout each form field with the validation rule and values applied. I’d like to see if the custom rule is ignored (which would be a bug I guess).

      Do you know what the possible values would be in advance? i.e. Could you use a validation rule like #LIST value1,value2,value x... ? If so, give that a try.

      As far as checkboxes and radio buttons are concerned there is no way at the moment to do the same. The parser will always compile a list of valid values from the from template. Something to look at in the future....

        • 33372
        • 1,611 Posts
        Thanks for the quick reply. I can’t test the sucker with debug on now because the clients rushed me into going live with it. But it definitely ignored the custom validation rules that I was intending to force-feed it (I tried using #EVAL return true; before making a list of countries, and when that didn’t work I assumed that #LIST wouldn’t either).

        It seems as if the same flag for hidden fields that will be modified via JS could be made to work for select fields, no?

        Anyway it’s a minor glitch in an otherwise fabulous script, and it’s easy enough to comment out two lines of code in order to make it work pretty much the way I want it to (there’s no validation on those fields now, but if I really cared about that I could use an event-triggered function).
          "Things are not what they appear to be; nor are they otherwise." - Buddha

          "Well, gee, Buddha - that wasn't very helpful..." - ZAP

          Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
          • 30223
          • 1,010 Posts
          It seems as if the same flag for hidden fields that will be modified via JS could be made to work for select fields, no?

          In principal yes..

          Anyway it’s a minor glitch in an otherwise fabulous script, and it’s easy enough to comment out two lines of code in order to make it work pretty much the way I want it to (there’s no validation on those fields now, but if I really cared about that I could use an event-triggered function).

          Well at least you’ve pointed at something I’ll have to have a look at sometime, although that won’t be too soon I’m afraid. This time of the year I’m rather busy with art related things, exhibitions and some time in the studio hopefully. smiley