Forums

Dynamic Validation

WhiteLighter01 04 Nov, 2016
Hi all,

In CF3 running on Joomla, I am able to do a dynamic validation using the code below

function makeRequired(el){
	el.addClass(req);
	formCheck_FormName.register(el);
}

function makeOptional(el){
    el.setProperty('class', '');
    formCheck_FormName.removeError(el);
    formCheck_FormName.dispose(el);
}


What would be the CF5 on WordPress equivalent to this? I'm aware about the FAQ regarding Custom Validation and it is working great on most of my forms. It is just this one form that I'm currently working on has so many variables that affects which field is required and which field are not required. I can go use the samples on the FAQ but debugging 250 lines of if/else logic would be difficult. So I'm planning to just call the function with the concerned fields to apply the validation as needed.

Thanks
GreyHead 05 Nov, 2016
Hi WhiteLighter01,

I have only a little experience with CFv5 on WordPress; that said, I would suggest that you switch to a different jQuery validation library to do dynamic validation. The ChronoForms library sets up the validations on form load and I have never found a good way to over-ride them after that*. While it may be possible it probably isn't worth the work involved. I have used jQuery Validation successfully before.

Bob

* The exception is that disabled inputs aren't validated but I don't think that helps in your case.
This topic is locked and no more replies can be posted.