Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Why Is the 1st Condition Being Skipped?

 
Greenhorn
Posts: 7
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Annotation-2020-01-12-095040.jpg
[Thumbnail for Annotation-2020-01-12-095040.jpg]
First condition being skipped when correct credentials are entered
Annotation-2020-01-12-095117.jpg
[Thumbnail for Annotation-2020-01-12-095117.jpg]
Same thing happens when incorrect credentials are entered
 
Marshal
Posts: 24820
60
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a misspelling in line 2.
 
Marshal
Posts: 67336
171
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always have the JavaScript debugger console open when developing JavaScript. You would have seen the syntax error.
 
Bear Bibeault
Marshal
Posts: 67336
171
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, learn how to use breakpoints. Stopping the execution and looking at the value of variables is far superior to just guessing by inspection.

Otherwise, you're fighting blind.

 
Saloon Keeper
Posts: 2874
370
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, since the values of the user and pass are only set when the script is initially loaded, and not when the validate function is called, the values will always be empty, regardless of what has been entered in to the form elements.
 
Bear Bibeault
Marshal
Posts: 67336
171
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:Also, since the values of the user and pass are only set when the script is initially loaded, and not when the validate function is called, the values will always empty, regardless of what has been entered in to the form elements.



Exactly. Something else easily uncovered in the debugger.
 
Ron McLeod
Saloon Keeper
Posts: 2874
370
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And unrelated to your problem, I'm not sure what a heading element is, but I would assume that it should be inside the body element.:
Please correct me if I am wrong
 
Your mother was a hamster and your father was a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!