View Single Post
  #3 (permalink)  
Old January 5th, 2012, 04:52 PM
jpjamie jpjamie is offline
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default Validating Multiple Similar TextAreas

hozdaman thanks for posting your code above as it will help me figure out a better way to validate some of my TextAreas. I have a 16 question multiple choice online quiz which is validated for the answers, however there are 16 associated comment (TextArea) sections. I want to limit these TextAreas in case somebody enters with a cut and paste "...all work and no play makes Jack a dull boy..." thousands of times. If it CAN be done it WILL be done!

So, is there a better way than writing the code 16 below times (different field names of course)? All work and no play does make Jack a dull boy!
Code:
if(Request["Q1Comments"].Length > 200){
            ModelState.AddError("Q1Comments","Your comment cannot exceed 200 characters");
        }
Reply With Quote