WEBSWAPP Silverlight ASP.NET 3.5 ASP.NET 2.0 ASP.NET 1.0
Cascading Lists
ITemplate
DDL in GridView
G/V MultiSelect
Nested GridViews
RegExp
DataGrid Reorder
Events fire twice
Hyperlink Field
TextBox
UpdateParameters
MultiView
TreeView
C# Demo VB Demo

Validation of textbox entries using Javascript and Validation controls

In this demo we have 3 input boxes for phone numbers. Any of them has to contain a valid phone according to the format (999) 999-9999 or be empty but at least one of them has to have valid entry. Invalid entries would mark the textbox. The textbox style would return to normal if the user deleted the invalid entry or corrected it. The form would not submit unless at least one phone number is entered and none of the entered phone numbers was invalid.

Each of those textboxes has its own regular expression validator, to ensure that the entry is valid on both the client and the server side

The entry is checked on the client side using a javascript and a regular expression during the onchange event of the textbox. If the entry is valid, it is copied to a hidden textbox which is monitored by a RequiredFieldValidator server to control to ensure that there is at least one valid entry that was made by the user in any of the textboxes.

 
Phone 1 Phone 2 Phone 3

Source code:

VB Demo source code