1
votes

In the registration view of my mvc3 project i want to validate multiple input fields. To be more precise, i need to check whether the User (firstname, lastname, street and postal) already exists. I tried it with the [Remote] validation together with the AdditionalFields property but for me it seems to be the wrong approach to solve that. (but i could be wrong).

What would be the best way to do the multiple fields validation, so that all four fields are checked for input? Do i have to write a custom validation with data annotation?

Thanks

2

2 Answers

0
votes

You have to access the database, right? Its not something you do in Attributes. What you need is a custom MembershipProvider.

0
votes

Hopefully this is the right answer to part of your question:

public class User {
    [Required]
    public String FirstName {get;set;}
    [Required]
    public String LastName {get;set;}
    [Required]
    public String Postal {get;set;}
    [Required]
    public String Street {get;set;}
}

This should validate that all 4 fields have input (client-side or server-side or both).