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

    is it possible to both use regular validation in eForm and combine this with the Filter command to do formatting on certain fields? F.e. we need to format zip-codes, phone-numbers etc. to a certain standard for later-on data-analyses. So we would like to first filter the field-data (f.e. remove spaces, or certain characters like - , etc.) and then validate the resulting value using the build in eForm validation. Can this be done in the form field definitions themselves?

    Olaf
      • 10226
      • 412 Posts
      This should be done with the field itself, it is tricky by my standards...

      You need to specify a few things such as ’maxlength’ and js come into play; onkeyup, onblur, value.replace

      The rest is programming your function with regex switches. This link should give you an idea of what you are getting into smiley

      http://javascript.internet.com/page-details/remove_xs_whitespace.html
        • 30223
        • 1,010 Posts
        No that’s not possible out of the box with eForm but you can achieve this by using the eFormOnValidate event. This event is triggered once all fields are correctly validated. In your event function you can then apply your filtering to any of the fields you want.

          • 22098
          • 218 Posts
          Quote from: TobyL at Aug 03, 2008, 06:03 PM

          No that’s not possible out of the box with eForm but you can achieve this by using the eFormOnValidate event. This event is triggered once all fields are correctly validated. In your event function you can then apply your filtering to any of the fields you want.



          i understand. The thing is i want to validate *after* filtering. F.e. in the netherlands lots of people enter zipcodes with spaces, but also without spaces. I first want to filter the spaces out of the data, and then validate for the format i need. This is a much more elegant way imho.
          Furthermore it would be very handy if non-programmers could also configure this in the form-html itself, just as they now can set up eForm validation.

          Olaf
            • 7231
            • 4,205 Posts
            I would check into a js to format the fields before validation. It could be triggered on focus. I have seen this a lot recently with credit card numbers and phone numbers to remove the -.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 22098
              • 218 Posts
              Quote from: dev_cw at Aug 05, 2008, 06:01 AM

              I would check into a js to format the fields before validation. It could be triggered on focus. I have seen this a lot recently with credit card numbers and phone numbers to remove the -.

              that is of course possible, but it would be so much nicer, faster and elegant to make this possible:

              <formfield .... eform:my_formfield:string:1::#FILTER:#VALIDATION> and of course make filter and validation optional fields.
              This way also non-programmers could make a very good form

              Olaf
                • 30223
                • 1,010 Posts
                I’ll keep this in mind, but I don’t think it’s going to happen any time soon. In the next version of eForm, if I ever get to finish it smiley, it will at least be a little easier to implement as you have access to all values in your validation/filter functions. You can then write a simple validation function which includes the filtering...