In my registration page I have land line phone number and mobile number fields.
I need to ensure that the user needs to add at least one phone number either the land line or mobile.
How do I do this?
Thanks Arnab
In my registration page I have land line phone number and mobile number fields.
I need to ensure that the user needs to add at least one phone number either the land line or mobile.
How do I do this?
Thanks Arnab
Adding a solution that can be applied to individual properties, rather than overriding the validation method at the class level...
Create the following custom attribute. Note the "otherPropertyName" parameter in the constructor. This will allow you to pass in the other property to use in validation.
You can then decorate your properties like so: (be sure to pass in the name of the other property to compare with)
You could write a custom validation attribute and decorate your model with it:
and then:
For more advanced validation scenarios you may take a look at FluentValidation.NET or Foolproof.