We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问题:今日遇到一个神奇的问题,用户那边反馈在input框粘贴手机号码,校验失败,原因是粘贴时带有特殊编码 解决方案:过滤掉不是整型的字符
function getTelPhone (phone) { if (typeof phone !== 'string') return '' var phoneReg = /[0-9]/ var phoneNum = '' for (i = 0; i < phone.length; i++) { if (phoneReg.test(phone.charAt(i))) { phoneNum += phone.charAt(i) } } return phoneNum } var phone = '13712312312' // 此处的phone是有特殊编码的,长度为13 console.log(getTelPhone(phone), getTelPhone(phone).length)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
问题:今日遇到一个神奇的问题,用户那边反馈在input框粘贴手机号码,校验失败,原因是粘贴时带有特殊编码
解决方案:过滤掉不是整型的字符
The text was updated successfully, but these errors were encountered: