Win a copy of Kotlin for Android App Development this week in the Kotlin 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

JavaScript Form Validation only Depends on first element  RSS feed

 
Greenhorn
Posts: 11
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My java-script works and all but the only problem is when the first and last name is correct it automatically ignores all the other form element and submits the form. But if the name elements are incorrect it validates the whole form. How do I get it to continue validating if first and last name is correct?

HTML:



Java:




 
author & internet detective
Posts: 39129
723
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check the JavaScript console in your browser? Maybe you are getting a syntax error?

If not, the next step is to try to make this a smaller example. Right now, it is a lot of code so the problem could be anywhere. Getting rid of some of the fields/validation will let you contain a smaller example that still illustrate the problem.
 
Marshal
Posts: 67226
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Jeanne responded, make sure you are using the browser's debugger. See if there are console errors, and set breakpoints to trace the execution path and check variables.

If you want people to look closely at your code, be sure to format it with correct indentation. As posted, your code is too hard to read.

And lastly, that is JavaScript code, not Java code.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!