Auto Format Phone Number in Jquery

后端 未结 6 2135
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 10:46

    Since you're using jQuery you can try jquery masked-input-plugin.

    There's a jsFiddle for you here where you can see how it works.

    The source code for the project on GitHub can be found here.

    The implementation is more than simple:

    HTML:

    
    

    javascript:

    $("#ssn").mask("999-999-999");
    

    UPDATE:

    Another good one can be found here.

提交回复
热议问题