· 7 years ago · Jan 25, 2019, 09:10 AM
1If you have ordered from us in the past, do you already work with one of our outside sales representatives?
2[checkbox* check-sales id:checksales "Yes" "No"]
3
4If you checked "Yes" which representative do you generally deal with?
5[select sales-rep id:sales include_blank "Marla" "Lisa" "Wendy" "Stacy" "Nicole" "Linda" "Jody" "Gisele" "Ray" "Craig"]
6
7[submit]
8
9function is_gmail($email) {
10 if(substr($email, -10) == '@gmail.com') {
11 return true;
12 } else {
13 return false;
14 };
15 };
16 function custom_email_validation_filter($result, $tag) {
17 $type = $tag['type'];
18 $name = $tag['name'];
19 if($name == 'your-email') { // Only apply to fields with the form field name of "your-email"
20 $the_value = $_POST[$name];
21 if(!is_gmail($the_value)){
22 $result['valid'] = false;
23 $result['reason'][$name] = 'This is not a gmail address!'; // Error message
24 };
25 };
26 return $result;
27 };
28 add_filter('wpcf7_validate_email','custom_email_validation_filter', 10, 2); // Email field
29 add_filter('wpcf7_validate_email*', 'custom_email_validation_filter', 10, 2); // Required Email field
30
31<script type="text/javascript">
32/*! jQuery script to hide certain form fields */
33$(document).ready(function () {
34
35 //Hide the field initially
36 $("#hide").hide();
37
38 //Show the text field only when the third option is chosen
39 $('#dropdown').change(function () {
40 if ($("#dropdown").val() == "Other") {
41 $("#hide").show();
42 var input = $("#hide");
43 if (input.length > 0) { //If the input field contains any value remove it
44 input.val('');
45 }
46
47 } else {
48 $("#hide").hide();
49 var input = $("#hide");
50 input.val("NA"); //add NA Value to hidden field that is required!
51
52 }
53 });
54});
55</script>