• 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

Validation Code

 
Ranch Hand
Posts: 126
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a course registration page that allows you to choose a course and then a section.  Right now, you can choose a course and a section that doesn't fit the course.
I want to create validation code that ensures that my course section is valid for for my course.  Here's what I'm trying:



And here is my entire code:



 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daniel,
Do you have a question about that code or just sharing? Is there something in particular that doesn't work?
 
Daniel Martos
Ranch Hand
Posts: 126
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Daniel,
Do you have a question about that code or just sharing? Is there something in particular that doesn't work?



Yes, I'm sorry.  The bit of code at the top isn't working and I'm looking for advice about why.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly how is it not working? What's happening differently than your expectations?

Have you learned how to set breakpoints to help with debugging?
 
Daniel Martos
Ranch Hand
Posts: 126
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Exactly how is it not working? What's happening differently than your expectations?

Have you learned how to set breakpoints to help with debugging?



This bit of code doesn't display the "You must select a valid section for CIS 100!" message, if the person selects an incorrect section.  It also bypasses the confirmation message and goes straight to the form processor on the next page.  I do not know about breakpoints.

 
Daniel Martos
Ranch Hand
Posts: 126
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry, that bit of code is:

 
Daniel Martos
Ranch Hand
Posts: 126
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it with a switch statement and it works to tell you if it you choose the incorrect section, but if you choose the right section it skips the rest of the validation (because it's returning true), doesn't print the confirmation message, and advances straight to the form processor page.  Any idea of how I can do this without returning true?  

 
Bear Bibeault
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

Bear Bibeault wrote:Have you learned how to set breakpoints to help with debugging?

 
reply
    Bookmark Topic Watch Topic
  • New Topic