Validating data in asp dating a person with herpes

15-Jun-2020 23:15

The recommended approach is to create a metadata class and decorate its properties with data annotation attributes. Add a new class in the Models folder and name it User Profile Metadata.

The [String Length] attribute is used to specify the maximum length and optionally the minimum length for a property value.

The [Display Name] attribute is used to specify a friendly name for the property under consideration.

This friendly name is used by HTML helpers such as Html. If you don't use the [Display Name] attribute a property name will be used for display purpose.

In this example you validate the Phone property with a regular expression for US phone numbers.

At this stage, the User Profile Metadata class is just an independent class in your project.

The [String Length] attribute is used to specify the maximum length and optionally the minimum length for a property value.

The [Display Name] attribute is used to specify a friendly name for the property under consideration.

This friendly name is used by HTML helpers such as Html. If you don't use the [Display Name] attribute a property name will be used for display purpose.

In this example you validate the Phone property with a regular expression for US phone numbers.

At this stage, the User Profile Metadata class is just an independent class in your project.

Add the following code to the Home Controller class.