I am working on an MVC project and I am new in MVC. I need to validate texts entered in the textbox. The value of this textbox can be different (file, text, and URL) in different cases. In other words, I have a enum class FileTypeEnum with three different values. So, the input for this textbox needs to validate 3 times i.e. 3 different cases. I did validate this textbox when it is a file. I need to validate the text entered when FileTypeEnum is text i.e. 7.
//validate for file i.e. ResourceTypeId == 8
if (resource.ResourceTypeId == 8)
{
//already done work for it.
}
else if (resource.ResourceTypeId == 7)
{
// Trying to validate in here for texts
// ^[a-zA-Z]+ ^.+\@.+\..+$
}
//validate for url i.e. ResourceTypeId == 9
else
{
// TODO
}
Above code is for the controller where I need to do validation. Please help.