Auto Format Phone Number in Jquery

后端 未结 6 2131
Happy的楠姐
Happy的楠姐 2020-12-15 10:20

I have one textbox for phone number. My phone number should be XXX-XXX-XXX like this format.

I got the solution for XXX-XXX-XXX format, but i don\'t know how to modi

6条回答
  •  自闭症患者
    2020-12-15 11:01

    You can set input mask on any field in 3 simple steps:

    1: First of all call these libraries http://code.jquery.com/jquery-1.7.2.min.js" "https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js"

    2: Create simple form like this :

    3: Then the script code past into your script tag..

    $(document).ready(function($) {

    $('#phone').mask("99999-9999999-9",{placeholder:""});
    

    });

提交回复
热议问题