• Resolved celebizs

    (@celebizs)


    This is the example page, i want to set every field obligatory. How can i do that?
    Only name and email is required, how can i set every one to be required too?

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @celebizs, in order to set the fields required, you have to edit the class-wc-Woocommerce-Catalog-Enquiry-frontend.php and make all the fields required. As you can see, we have set the Email, Name, Captcha required via $error_levels = array();. So, pass the additional fields that are also required under this.

    You can refer to this link for further details: https://github.com/dualcube/woocommerce-catalog-enquiry/blob/master/classes/class-wc-Woocommerce-Catalog-Enquiry-frontend.php

    Let us know if you have any further query,

    Thread Starter celebizs

    (@celebizs)

    Hello @wc Marketplace , How do i do that? I add the following lines to the array:
    // error levels
    $error_levels = array();
    $error_levels[‘name_required’] = __(‘Nome é obrigatório’, ‘woocommerce-catalog-enquiry’);
    $error_levels[’email_required’] = __(‘Email é obrigatório’, ‘woocommerce-catalog-enquiry’);
    $error_levels[’email_valid’] = __(‘Coloque um e-mail válido’, ‘woocommerce-catalog-enquiry’);
    $error_levels[‘comment_required’] = __(‘Informe a data de nascimento’, ‘woocommerce-catalog-enquiry’);
    $error_levels[‘phone_required’] = __(‘Informe um telefone.’, ‘woocommerce-catalog-enquiry’);
    $error_levels[‘address_required’] = __(‘Informe um CPF’, ‘woocommerce-catalog-enquiry’);

    But it didnt work ??

    Hi @celebizs, we check the validation of the field using jquery, so you have to modify the jquery and add the validation also.

    Thread Starter celebizs

    (@celebizs)

    Can you give me a simple example of how to do it? Please…. ;))

    Hi @celebizs, there is no such ready-made code with us, however, you can look into our GitHub repository to check how we are using jquery to validate the email and name : https://github.com/dualcube/woocommerce-catalog-enquiry

    I manage to make the phone field as required. And share it over here if that is not too late.

    /plugins/woocommerce-catalog-enquiry/classes/class-wc-Woocommerce-Catalog-Enquiry-frontend.php

    add the code under // error levels

    $error_levels['phone_required'] = __('Phone is required field', 'woocommerce-catalog-enquiry');

    /plugins/woocommerce-catalog-enquiry/assets/frontend/js/frontend.js

    add the code under var email = document.getElementById(‘woo_user_email’).value;

    var phone = document.getElementById('woo_user_phone').value;

    find the email validation condition.
    if (email == ” || email == ‘ ‘) {
    document.getElementById(‘msg_for_enquiry_error’).innerHTML = catalog_enquiry_front.error_levels.email_required;
    document.getElementById(‘woo_user_email’).focus();
    return false;
    }

    add the following code under it.

    if (phone == '' || email == ' ') {
        document.getElementById('msg_for_enquiry_error').innerHTML = 
            catalog_enquiry_front.error_levels.phone_required;
            document.getElementById('woo_user_phone').focus();
            return false;
    }
    • This reply was modified 6 years, 1 month ago by madbug.

    Hi @madbug, thanks for helping out other users also.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to set every field required?’ is closed to new replies.