格式化电话号码的指令
问题描述:
我想知道如何使用 angularjs 指令自动格式化输入字段中的数字?当我在输入字段中输入 6042919283 时,我希望它显示为 604-291-9283.
I was wondering how to automatically format a number in an input field using an angularjs directive? When I type in an input field say 6042919283 I want it to be shown as 604-291-9283.
谢谢
答
你可以使用 UI Utils mask它允许您定义允许的输入格式,并将为您处理验证以及格式
You could use UI Utils mask It allows you to define an allowd input format and will handle the validation for you as well as the formatting