MVC4 : Manually set the validation message from the server side

Viewed 5234

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??
 }
1 Answers
Related