0

I'm struggling on logic here - can i get some ideas please! :)

basically i have a c# MVC3 application that accepts a huge amount of text (100+ text areas), modifies it, and then outputs it.

i want to check the length of the combined text boxes and have the process fail validation if they are over X length.

the only solution i can think of is by combining all the text into a string server side and get the length. I'm expecting my competitors to fully abuse the system and attempt to overload my servers when i go live, so i want to try and validate on the client side too if possible.

can anyone think of an efficient way to do this (client or server-side if you have a nice idea).

tereško
  • 58,060
  • 25
  • 98
  • 150
loveforfire33
  • 1,090
  • 3
  • 25
  • 46

2 Answers2

0

You could use maxlength css property or you could decorate your model with [StringLength] data annotation to check length of the string

fenix2222
  • 4,602
  • 4
  • 33
  • 56
0

Build a custom validator using a technique similar to this answer by Daron Dimitrov. That will do the check on both client and server side and you can use a ViewModel to decorate the attribute to apply to all of the inputs.

Community
  • 1
  • 1
Turnkey
  • 9,266
  • 3
  • 27
  • 36