Featured On ...

asp.net

totalasp.co.uk

fuzzysoftware.com

devdex.com

123aspx.com

dotnetfreaks.com

411asp.net

and more ...

ASP.NET Validation Package Demo 3 - Multiple non-ASP.NET server forms

The following demo contains three non server forms, each independently being validated. The first form collects basic user information from a subscriber and contains a series of validation rules as follows:

  • The name, street, town, and country cannot be left blank.
  • The date of birth is optional, but the person subscribing must be older than 18. The field accepts either a US date format (MM/DD/YYYY) or a format that could not be considered to be ambiguous.
  • The email address must be a valid email address and cannot be left blank.

The second form is a login form (it doesn't actually log into anything). It contains two basic validation rules as follows:

  • Both the username and password must adhere to the regular expression ^[a-z][a-z0-9-_.]{4,19}$

The login form is used later to demonstrate server-side only validation.

The third form is a basic search form that contains two search term fields and a condition. The validation rules for this form are a little more complex than the others. The rules follow:

  • The first search term is required.
  • If a condition is selected, the second search term must not be blank.
  • If no condition is selected, the second search term must be blank.

Note that the code used to create this page contains no server form elements whatsoever. Consequently, all form fields that are validated must be registered with the Validator as belonging to a group. The submit button for each of the forms is linked to its associated group so that the Validator knows which fields to validate server-side.

In this example, all forms and validation entries are placed on the same ASPX page. However, to maintain good design this should not be the case in a real situation. Ideally all validation and form handling should be isolated from one another and placed in individual user controls.

>> Show me the code!

>> Turn off client side validation!




Subscribe
Name
Street
Town
Country
Date of birth
Email

Login
Username
Password

Search
Search term 1
 
Search term 2

© 2002 - 2008 Copyright, Disclaimer and Privacy Statement