我怎么解决这个问题 ? : 在没有正则表达式的情况下至少允许一个数字字符

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;
}

我在这里使用了正则表达式,但我不想使用它,所以解决方案是什么?

您可以使用函数 isNaN 检查每个字符,此函数 returns 如果它是数字字符则为 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')
}