如何将任何字符从电话字段中删除 [英] How do I strip any characters out of the telephone field
本文介绍了如何将任何字符从电话字段中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从电话字段中去除所有非数字字符,包括空格.我需要一串数字0-9.没有()或空格.
How do I strip any characters that are not a number out of the telephone field, including spaces. I need to have a string of numbers 0-9. No () or spaces.
我有一个用于电话(999)999-9999的掩码输入
i have a maskedinput for telephone (999) 999-9999
Phone Number:
<input id="phone" type="text" /> (999) 999-9999
我只需要 9999999999
我正在使用maskedinput插件 http://digitalbush.com/projects/masked-input-插件/
i am using maskedinput plugin http://digitalbush.com/projects/masked-input-plugin/
推荐答案
var str = "(999) 999-9999";
str = str.replace(/\D/g,'');
删除所有不是数字\D
的内容.
Removes anything that is not a digit \D
.
这篇关于如何将任何字符从电话字段中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文