This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes Validating a group of input strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Validating a group of input strings" Watch "Validating a group of input strings" New topic

Validating a group of input strings

John Zwick
Ranch Hand

Joined: Mar 02, 2009
Posts: 34
I have 25 input boxes of which are grouped into 5 "messages", each containing 5 lines.
Any suggestions or tips on efficiently validating these text boxes? For example, Messages #2-5 cannot have any values unless Message #1 has values. Also, for a given message, a line can only have values if all the lines before it have values (for example, a message cannot contain values in line 1 and line 5 but not 2,3, or 4).

Is there a more efficient way of doing this without using a ton of if's? In my backend code, each line is assigned to a String object (e.g message2Line3)

Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Two loops will do it.

This should help you ... Post your code once it's done or you have further questions...

EDIT: instead of naming each block message1Line1, message1Line2 etc, name it simply message1. The container makes an array of it.

JDBCSupport - An easy to use, light-weight JDBC framework -
subject: Validating a group of input strings
jQuery in Action, 3rd edition