• 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
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • 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: 26100
71
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: 67478
173
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: 67478
173
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.

 
Marshal
Posts: 3255
487
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus 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: 67478
173
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
Marshal
Posts: 3255
487
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus 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
 
eat bricks! HA! And here's another one! And a tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic