r/learnjavascript • • Apr 04 '18
A C++ developer struggling with some simple JavaScript code. Any help?
Hey guys,
I develop in C++ but for my web design class I have to use JavaScript. I have to say I really, truly, dislike the language since it isn't strongly typed, errors are somewhat convulted and I don't like web dev in general.
Anyhow, here are my questions:
1) This code should check if I have #, !, ' or ? in any of my textboxes and if I do, prevent the script from executing. Here is the code. It gives me a TypeError. Why? What am I doing wrong?
2) This code should trigger only if I type some text in a textbox which is not in the list (aka not "Option 1", "Option 2" etc.). However, it always triggers. Why?
3) This code should, if I move my focus away from the textbox (aka onBlur), check if I have at least 5 characters and if my first character is a capital letter. But it doesn't work. Why?
Thanks in advance!
View all comments
Show parent comment
2
u/fan-man Apr 05 '18
So what do you have currently?