Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Hi,

I have applied validation and it is working fine.

For ex.

[LocalizedRequired(ResourceName = (ResourceFile.Setting), ResourceKey = ServerSettingResources.Required)]
[LocalizedRegularExpression("[^<>]*$", ResourceName = (ResourceFile.Setting), ResourceKey = ServerSettingResources.IllegalCharacterMessage)]
public string CustomField { get; set; }

It is working fine for illegal character.

This CustomField  used for 2 to 3 views.

I am using boelow code in view-

@Html.TextBoxFor(model => model.CustomField , new { maxlength = "20" })
@Html.ValidationMessageFor(model => model.CustomField, null, new { @id = "ValidationMessage" })

Now,

I want to apply email validation when my scenario for email at this time i want to apply email validation as well, otherwise i want to perform illegal character validation only.

How would i achieve this ?

Thanks.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900