pakistan contact js validation code example

Example: pakistan contact js validation

/**
* @author: Mr. Waseem
* @notice: Below script will validate the Pakistani contact number 
* e.g. (3333333333). excluding the +92 or 0 from start
*/
let regx_cell = /^\d{3}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/;
        $('.other_respondent_contact').on('keypress keydown keyup', function () {
            if ($('.other_respondent_contact').val().length > 0) {
                if (!$(this).val().match(regx_cell)) {
                    $(".contact-error-respondent").html("Invalid contact no");
                    $(this).css('border', '1px solid red');
                    $("#save_case").prop("disabled", true);
                } else {
                    $(".contact-error-respondent").html("");
                    $(this).css('border', '1px solid #ccc');
                    $("#save_case").prop("disabled", false);
                }
            }
            else {
                $(".contact-error-respondent").html("");
                $(this).css('border', '1px solid #ccc');
                $("#save_case").prop("disabled", false);
            }
        });