Text Field affecting another Text Field's required* to submit form
Vincent created the topic: Text Field affecting another Text Field's required* to submit form
Hello Guys!
I would like to check on how to make a text field required* (required to fill in) based on if another text field is filled.
For example if I have a text field for Name and Email like this:
Name:
Email:
Once someone keys in something into the Name text field the Email text field becomes compulsory to fill in:
Name: John Doe
*Email:
Any advice on how to do this?
Thanks!
Please Log in or Create an account to join the conversation.
6 years 7 months ago
Agapi G. replied the topic: Text Field affecting another Text Field's required* to submit form
Hello Vincent!
Thank you for posting this question!
Perhaps the best way to do this would be to write a few lines of additional Javascript code. You can add it to Form Options of your form, Javascript tab. In case you are not sure about the code, please submit a support ticket using
this form
, and we'll help you out.
Please send temporary WordPress administrator access to your website, and also include the link to this forum thread in your message.
Thanks! Have a great day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
6 years 7 months ago
Agapi G. replied the topic: Text Field affecting another Text Field's required* to submit form
Hi Vincent!
I am happy to inform you, that our development team has just sent the code which you will need to use. Please go to Form Options > Javascript tab of your form and add the following code to before_load() function:
jQuery('#wdform_1_element_first1').keyup(function(){
if(jQuery(this).val() != ""){
if(jQuery.inArray("2", required_fields1) === -1){
required_fields1.push("2");
jQuery("div[type='type_submitter_mail'] .wdform-label").after('<span class="wdform-required">*</span>');
}
} else{
var index = required_fields1.indexOf("2");
if (index > -1) {
required_fields1.splice(index, 1);
jQuery("div[type='type_submitter_mail']").find('.wdform-required').remove();
}
}
});
Please make sure to replace the ID of the field with the one on your form. Let me know if there's anything else I can assist you with.
Thanks! Have a great day!
Kind regards,
Agapi G.
Web-Dorado team
Please Log in or Create an account to join the conversation.
6 years 7 months ago