格式化电话号码的指令 [英] A directive to format phone number

本文介绍了格式化电话号码的指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用 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

这篇关于格式化电话号码的指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆