ASP.NET Validation Tutorial
This article describes how to quickly add thorough validation of postcodes, telephone
numbers and email addresses, far beyond what can be achieved using only standard
regular expression validators.
To follow this tutorial you will need to have installed our
ASP.NET Data Capture &
Validator pack, which you can download free of charge. You will also need to
have registered for an account with us and arranged
with your account manager to get access to the
Postcode Lookup,
Telephone Validation
and Email Validation services. You
can call us now on 0151 355 4555 to arrange these details and ensure that you are
given the services that are best for you.
Validating Postcodes
If you're using our ASP.NET AddressCapture control for everywhere that your users enter
addresses, you don't need worry about validating postcodes as this functionality is
already built into that control. However, if you've got a simple set of text boxes,
you can use our PostcodeValidator control to ensure they are correct.
Open your web page in the Visual Studio designer. After installing the validator controls,
you should now have a Data8 tab in your toolbox.

Drag & drop a PostcodeValidator control from the Data8 toolbox onto your page to
start adding postcode validation.

In the Properties window, set up the ControlToValidate and ErrorMessage properties as you
would for any normal validator control. Also set the Username, Password and Licence
properties to the appropriate values for your account - if you are unsure of these values,
please contact your account manager.

That's it! Any values entered into the text box will be validated as correct postcodes,
and you don't need to change any code.
Validating Telephone Numbers
If your website allows users to enter telephone numbers you're probably validating them
with a regular expression validator, but by using our data-driven validator you can be
sure that the number that has been entered has actually been allocated for use and contains
the correct number of digits for that particular exchange - most exchanges use 10 digit
numbers while others use only 9. Validating telephone numbers to this level of detail
ensures that only accurate data is captured, and typing errors or deliberate attempts to
enter invalid numbers are prevented.
Open your web page in the Visual Studio designer. After installing the validator controls,
you should now have a Data8 tab in your toolbox.

Drag & drop a TelephoneValidator control from the Data8 toolbox onto your page to
start adding telephone number validation.

In the Properties window, set up the ControlToValidate and ErrorMessage properties as you
would for any normal validator control. Also set the Username and Password
properties to the appropriate values for your account - if you are unsure of these values,
please contact your account manager.
That's it! Any values entered into the text box will be validated as correct telephone numbers,
and you don't need to change any code.
Validating Email Addresses
You probably already use regular expressions to validate any email addresses entered onto
your site, but that doesn't stop people entering invalid addresses such as mickeymouse@example.com.
Our Email Validation service goes a step further to check that the domain part of the address
is set up to receive email in order to prevent accidental typing errors (e.g. info@data-9.co.uk
rather than info@data-8.co.uk) as well as deliberately incorrect addresses.
Open your web page in the Visual Studio designer. After installing the validator controls,
you should now have a Data8 tab in your toolbox.

Drag & drop an EmailValidator control from the Data8 toolbox onto your page to
start adding email address validation.

In the Properties window, set up the ControlToValidate and ErrorMessage properties as you
would for any normal validator control. Also set the Username and Password
properties to the appropriate values for your account - if you are unsure of these values,
please contact your account manager.
That's it! Any values entered into the text box will be validated as correct email addresses,
and you don't need to change any code.