1

I am building a form using Solspace Freeform, and we have two fields for telephone numbers - one for landline and one for mobile/cell.

Is it possible for me to make one or other of these fields required? I.E. If the user fills out landline but not mobile the form will submit, if the user fills out mobile but not landline the form will submit, but if the user doesn't fill out either then the form will return an error?

Thanks in advance!

2

You could try to solve with Jquery with depend function like so

$(".selector").validate({
    rules: {
        contact: {
            required: true,
        email: {
                depends: function(element) {
                     return ($('#theRequiredField').val() == '';
                }
        }
     }
}

SOURCE: http://jqueryvalidation.org/validate#toptions search " depends:"

1
  • 1
    Unfortunately there is no way within Freeform to set the required="" feature dynamically or to control the requirement of one field based on the value of another. Once values are set in the required="" parameter (or in the Composer editor), they can't be changed. The above solution is what we would suggest instead, and requires javascript/jQuery and a validation script.
    – Solspace
    Sep 11 '13 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.