Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Well the removeClass thingy didn’t work out ??

    Here’s the code I tried if someone is willing to help:

    // Contact form conditional toggle
    	$('#subject-menu').change(function() {
    		var subject = $(this).val();
    		if (subject == "Reservation" || subject == "Event") {
    			$('#form_subject_toggle').show(1000);
    			$('#form_attachment_toggle').hide(1000);
    			//$('#form_subject_toggle').find('input').toggleClass('wpcf7-validates-as-required');
    		} else {
    			$('#form_subject_toggle').find('input').removeClass('wpcf7-validates-as-required');
    			$('#form_subject_toggle').hide(1000);
    			$('#form_attachment_toggle').show(1000);
    		}
    	});

    I’ve also thought about hiding conditionally with jquery, but some issues come to mind:

    • Hiding required fields
    • Conditional email text

    I’m currently creating a contact form for reservations or simple feedback. For this I have a drop-down menu from which the user has to choose a subject. If “Reservation” is chosen, I’ll fade in fields for date, time and number of persons to reserve a table for. Those are required fields. If the subject is “Feedback”, the above would be hidden and the form would not submit.

    Maybe a possible solution would be to use
    $('.selector').removeClass('wpcf7-validates-as-required')
    but I haven’t tested this yet.

    As for the email, I don’t have any ideas. Currently I have something like this:

    Date: [date]
    Time: [time]
    Number of Persons: [persons]

    I don’t want “Date”, “Time” and “Number of Persons” to be part of the message body when there is nothing beside them (speak user didn’t fill the appropriate fields)

    Would be thankful if someone comes with a solution.

Viewing 2 replies - 1 through 2 (of 2 total)