How can I revise this code. It works but how can it be made better as far as javascript only. | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

How can I revise this code. It works but how can it be made better as far as javascript only.

https://code.sololearn.com/Wa23a9A90a17/?ref=app

14th Jun 2021, 1:00 AM
Edward Jackson Jr
Edward Jackson Jr - avatar
3 Respuestas
+ 2
function checkValid() { let inp = usrInput.value, num = inp.replace(/\D+/g,''), spe = inp.replace(/[^!#@*&%]+/g,''); if (inp) { if (inp.length<7 || num.length<2 || spe.length<1) { output.innerHTML = "Please enter a password that meets the above requirements."; form.reset(); } else { output.innerHTML = "digit count: "+num.length+"<br>special char count: "+spe.length; } } else output.innerHTML = "Please enter a password"; }
14th Jun 2021, 4:10 AM
visph
visph - avatar
+ 1
ODLNT yes, you're right: thank you... now corrected ;)
14th Jun 2021, 7:30 AM
visph
visph - avatar
0
Use regex. Its simple and efficient.
14th Jun 2021, 3:56 AM
Aravind Shetty
Aravind Shetty - avatar