This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Validation Code  RSS feed

 
Ranch Hand
Posts: 126
1
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 38152
617
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Author and ninkuma
Marshal
Posts: 66611
161
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 66611
161
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!