0

Javascript

var format = (555)555-5555

"keypress #clientphonenumber": function (event) {
        var keycode = event.which;
        if (!(event.shiftKey == false && (keycode == 46 || keycode == 8 || keycode == 37 || keycode == 39 || (keycode >= 48 && keycode <= 57)))) {
            event.preventDefault();
             $("#modaldescription2").empty();
            $("#modaldescription2").append("<b>Only Numbers are allowed</b>");
            $('#dialogPanel2').modal({
                dimmerSettings: {
                    variation: 'inverted'
                }
            }).modal("show");
        }
    },

Html

<div class="field">
       <b>Client Phone Number</b>
       <input type="text" id="clientphonenumber" value="<%- clientphonenumber%>">
    </div>

I need to validate a phone number on keypress using the above format i had tried above method but it not accepting () and - . can anyone help me with this

chethu
  • 386
  • 1
  • 3
  • 26

0 Answers0