• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Validating a group of input strings

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)


 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic