![](/img/trans.png)
[英]javascript regex to allow at least one special character and one numeric
[英]how can I solve this problem ? : At least one numeric character allowed without regex
if(password.search(/[0-9]/)){
document.getElementById('fpasswords').innerHTML="*atleast one numeric character";
return false;
}
在这里我使用了正则表达式,但我不想使用它,那么解决方案是什么?
您可以使用 function isNaN 检查每个字符,如果不是,则此 function 返回 false 和 true:
const str = 'Papayas1';
for (var i = 0; i < str.length; i++) {
if(!isNaN(str.charAt(i))) console.log('this is a number')
else console.log('this is not a number')
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.