views:

105

answers:

1

When validating an email address with the regex validation component, an additional RequiredFieldValidator must be added to ensure there is a value present.

I've mostly taken care of this with a CustomFieldValidator, and taking care of this with Javascript.

Is there a better way of doing this?

+2  A: 

Why wouldn't you just use the RegularExpressionValidator and the RequiredFieldValidator?

If you use a CustomFieldValidator you will need to implement a javascript check and a server side check as well. Using the other two validation controls together need no extra implementation except for a couple of attributes being set and it is the expected way of doing this type of validation with WebForms.

Consider the next programmer that is going to come along and see your different setup and wonder why you went to all this extra work when none of it was needed.

Kelsey