I want to validate some form fields in the server side, but I don’t want to use Data Annotations Custom Validators.
I need to manually set its value based on the return of the called Business Layer Method to define this message.
Just as an example!
NEED:
If the given username already exists, the MVC4 validation error span shall display “This username already exists.”
CODE:
if (_business.UserNameExists(username))
{
// Set the field validation error span message
// HOW TO DO??
}
A friend came with the solution, it is very simple!
Where UserName is the name of the Entity attribute being validated.