Hi,Neha
Make change on hear path:
woocommerce-catalog-enquiry\classes\class-wc-Woocommerce-Catalog-Enquiry-frontend.php
Add code for Email & phone validation.
Add this code after “if (email == ” || email == ‘ ‘)” this condition at line no 410.
if (!isValidEmailAddress(email)) {
document.getElementById('msg_for_enquiry_error').innerHTML = '<?php echo __('Email is not valid', $WC_Woocommerce_Catalog_Enquiry->text_domain); ?>';
document.getElementById('woo_user_email').focus();
return false;
}
if(phone !=""){
if(!validatePhone(phone)){
document.getElementById('msg_for_enquiry_error').innerHTML = '<?php echo __('Phone is not valid', $WC_Woocommerce_Catalog_Enquiry->text_domain); ?>';
document.getElementById('woo_user_phone').focus();
return false;
}
}
Add this fuction before function do_toggle() at near line no 500
function isValidEmailAddress(emailAddress) {
var pattern = /^([a-z\d!#$%&'*+\-\/=?^_<code>{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_</code>{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
return pattern.test(emailAddress);
};
function validatePhone(Phone) {
var filter = /^[0-9]{10}$/;
if (filter.test(Phone)) {
return true;
}
else {
return false;
}
}
Others suggestion use different class then “responsive” for popup when non technical person use your plugin in site “responsive” class to called responsive menu on first click in popup.
Regards,
Ravi patel