• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaScript Form Validation only Depends on first element

 
Greenhorn
Posts: 11
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic