Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rajeshsingh520/3a80a4c4e6fdec1959cc0567ef7e4dc8 to your computer and use it in GitHub Desktop.

Select an option

Save rajeshsingh520/3a80a4c4e6fdec1959cc0567ef7e4dc8 to your computer and use it in GitHub Desktop.
10 digit phone number calidation for the enquiry cart plugin
<?php
add_action('wp_enqueue_scripts','restrictPhoneNumber');
function restrictPhoneNumber(){
$js = '
jQuery(document).ready(function($){
jQuery("input[name=\'pi_phone\']").attr("data-rule-minlength","10");
jQuery("input[name=\'pi_phone\']").attr("data-rule-maxlength","10");
jQuery("input[name=\'pi_phone\']").attr("data-msg-minlength","Phone number should be of 10 digits");
jQuery("input[name=\'pi_phone\']").attr("data-msg-maxlength","Phone number should be of 10 digits");
});
';
wp_add_inline_script('jquery', $js, 'after');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment