Skip to content

Instantly share code, notes, and snippets.

@cartimize
Last active January 11, 2022 09:19
Show Gist options
  • Save cartimize/0f69167718575776449f6daabdf47d13 to your computer and use it in GitHub Desktop.
Save cartimize/0f69167718575776449f6daabdf47d13 to your computer and use it in GitHub Desktop.
Shipping and Billing full name Javascript and php validation
// Shipping full name validation
jQuery( document.body ).on( 'cartimize_shipping_full_name_validation', function(event, defaultResult, fieldValue){
//Add your custom code here. Return true or false else it will use default validation
//Example: Check fieldValue empty or not
if(fieldValue.length === 0 ){
return false;
}else{
return true;
}
});
// Billing full name validation
jQuery( document.body ).on( 'cartimize_billing_full_name_validation', function(event, defaultResult, fieldValue){
//Add your custom code here. Return true or false else it will use default validation
//Example: Check fieldValue empty or not
if(fieldValue.length === 0 ){
return false;
}else{
return true;
}
});
<?php
add_filter('cartimize_front_end_parsley_errors', 'cartimize_custom_cartimize_front_end_parsley_errors', 10, 1);
function cartimize_custom_cartimize_front_end_parsley_errors( $value ){
$value['parsley_errors']['shipping_fullname']= esc_html( 'This value is required.');
$value['parsley_errors']['billing_fullname']= esc_html( 'This value is required.');
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment