tags:

views:

90

answers:

3

I want to do simple things anyone in my web app like Checker.Email(string) which would return true or false after doing some regex or something. But I don't want to make this whole thing myself if one already exists...

+1  A: 

If you're using webforms, there are several ValidationControls you can place on the from, and a slew of third-party controls that use the same system (Inherit BaseValidator or CustomValidator).

Joel Coehoorn
I am using ASP.NET MVC, and have recently been confused about exactly how to wire up some validation. At the moment I am ready to just hand write a checker into my repositories that returns and error code and then just figure out a way for it to hand it back to the form after submit has happened.
shogun
I haven't looked at MVC much yet, but IIRC MVC 2.0 will have much improved/simplified validation helpers. Not that this helps you right now ...
Joel Coehoorn
Try looking at this question http://stackoverflow.com/questions/153039/asp-net-mvc-client-side-validation
Lazarus
+2  A: 

If you are using ASP.NET then I'd look at the RegularExpressionValidator that's one of the standard .Net Framework controls. Then grab an email regex from www.regexlib.com.

Lazarus
A: 

You can use Data Annotations. There is a little tutorial at asp.net/mvc. There's also a DataType attribute that will validate an email for you. If use this method, there's xVal by Steve Sanderson which really makes client/server side validation pretty simple.

scottm