Highlighted

Validation of field to always call JS function

James_R_Green

29-11-2018

Hi,

I want to store as much of the JS associated with my forms as possible in clientlibraries so that I can re-use and version control the code.

I can do this for the majority of tasks on the form using the guidebridge, but I don't have a satisfactory solution to the following.

Currently my validation works like this:

  • Each field I create has a call to "myvalidation.validateField(this);" added via the rules editor on the validate event
  • myvalidation.validate checks the this.name and applies the validation applicable to that field e.g. email, telephone etc

This works ....but I have to add a call to myvalidation.validate(this); to each field I create and the XML code that is stored on the form for the validation is unreadable.

Can this be done programatically so I don't have to configure this each time?

I tried on form load to gb.visit each field and overwrite the validateExp...but this 1) didn't work 2) is hacky

I could probably do something like call myvalidation.validate(this) when element focus changes and call it again on submit start or something, but I think this will then not be re-run by the "Enable serverside validation" option (which i need to use).

Any other way to do this?

Thanks,

Jim