Validating at least one field is completed

dlwilson007 04 May, 2014
Just curious...I have a form with a phone field and an email field. I'd like to make sure that the user completing the form adds at least one of the fields, but not necessarily both.

Is there a way to do this with Chronoforms? I suspect it might be along the lines of dynamic validation that would require some javascript and whatever else, but I'm thinking there could be a form action after submit that checks to see if one of the fields is completed.

Any thoughts?
Max_admin 05 May, 2014
Hi dlwilson007,

Just add a custom validtaion rule for each one of them and use a code like the one below for the custom function:

function checkOne(elem){
if(elem.val() || $("#ID_OF_THE_OTHER_ONE").val()){
return true;
}
return false;
}

Where "ID_OF_THE_OTHER_ONE" is the field id of the other field, you need 2 functions of this, with different names, assigned for the 2 fields!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.