Edit 02/05/2011
Ok, so i need to make my validation clientside, so I need what asked for below in c# to actually be in jquery. I will also be validating server side so I would appreciate more input there.
Original Question
Well, im on a real noob question trip today!!!
My previous question was for a specific regex. Now I have it and it works..how can I roll it out over multiple text boxes? I don’t want to use multiple Regular Expression Validation tools as they would clutter up my design space and I don’t think it’s a very elegant solution (It’s for a degree project)
Is there a method I could write? Along the lines of
public validator(string)
{
doessomething.tostring
return true/false
}
and access by
if (validator(txtsomething.text.tostring()) = true)
{
Dothis
}
else
{
dothis
}
Please be patient if my question is garbage 🙂
Thanks“
How about creating a custom control? I’ve edited my answer to include jQuery as well as server side validation. I don’t know what regex you’re using so I’ve just used a simple one testing for letters only.
javascript (also include the jQuery file):
.aspx page:
code behind:
Hope this helps!