Phone mask with jQuery and Masked Input Plugin

前端 未结 15 1453
夕颜
夕颜 2020-11-28 06:54

I have a problem masking a phone input with jQuery and Masked Input Plugin.

There are 2 possible formats:

  1. (XX)XXXX-XXXX
  2. (
15条回答
  •  粉色の甜心
    2020-11-28 07:45

    I was developed simple and easy masks on input field to US phone format jquery-input-mask-phone-number

    Simple Add jquery-input-mask-phone-number plugin in to your HTML file and call usPhoneFormat method.

    $(document).ready(function () {
        $('#yourphone').usPhoneFormat({
            format: '(xxx) xxx-xxxx',
        });   
    });
    

    Working JSFiddle Link https://jsfiddle.net/1kbat1nb/

    NPM Reference URL https://www.npmjs.com/package/jquery-input-mask-phone-number

    GitHub Reference URL https://github.com/rajaramtt/jquery-input-mask-phone-number

提交回复
热议问题