+ 1
Form Validation (JavaScript)
I want to explicitly check that a user doesnât input numbers in a name field... I ran this code to just test that it works on the console but it doesnât. If I input numbers it the name field, the statement still fires... let fName = document.getElementById(âfNameâ) fName = addEventListener(âchangeâ, () => { If (fName !== typeof Text) { console.log(âenter alphabets onlyâ); } });
6 Answers
+ 2
This page has an example using RegEx, hope it helps
https://www.fwait.com/how-to-check-if-string-contains-numbers-in-javascript/
+ 1
What should happen when they type "George Edison the 5th" as name?
+ 1
Ipang It should throw an error. âGeorge Edisonâ alone should suffice.
+ 1
Ipang Thank you very much đđŸ
+ 1
Furqan_Elahie [Imaziue Coders] You rock! Thank you