简体   繁体   English

如何从文本字段onblur中删除所有非数字?

[英]How can I remove all non numeric digits from text field onblur?

How can I remove all non numeric digits from text field with onblur=? 如何使用onblur =从文本字段中删除所有非数字位数? need to take out () and - from phone number before submit. 需要先从电话号码中取出()和-,然后再提交。

function cleanInput(string){
   return string.replace(/\D/g,'');
}

That will return a string with no non-numeric characters, just set the input's value to the result 这将返回没有非数字字符的字符串,只需将输入的值设置为结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM