+ 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 odpowiedzi
+ 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