Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Input / Validation

Registration form
Name:
Age:
Phone:
Email
Hire Date:





  • Type some data in the input controls then press the submit button. ASP.NET validation would fail in case of invalid or missing data.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" CodeFile="DefaultVB.aspx.vb" AutoEventWireup="false" Inherits="Telerik.InputExamplesVB.Common.Validation.DefaultVB" %>

    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag runat="server" ID="Headtag1"></qsf:HeadTag>
        <!-- custom head section -->
        <!-- end of custom head section -->
        <style type="text/css">
            .FormContainer DT LABEL
            {
                float: left;
                width: 100px;
            }
            .FormContainer LABEL
            {
                line-height: 20px;
            }
            #CheckBox1
            {
                vertical-align: middle;
            }
            IFRAME
            {
                border-right: red 1px solid;
                border-top: red 1px solid;
                border-left: red 1px solid;
                border-bottom: red 1px solid;
            }
            FIELDSET
            {
                border-right: #ccc 1px solid;
                padding-right: 5px;
                border-top: #ccc 1px solid;
                padding-left: 5px;
                padding-bottom: 5px;
                border-left: #ccc 1px solid;
                padding-top: 5px;
                border-bottom: #ccc 1px solid;
            }
        </style>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <qsf:Header runat="server" ID="Header1" NavigationLanguage="VB" XhtmlCompliant="False">
        </qsf:Header>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <fieldset>
                <legend>Registration form</legend>
                <br />
                <table border="0" cellpadding="5">
                    <colgroup>
                        <col width="100" />
                        <col width="500" />
                    </colgroup>
                    <tr class="FormContainer">
                        <td>
                            Name:
                        </td>
                        <td>
                            <telerik:RadTextBox ID="RadTextBox1" runat="server">
                            </telerik:RadTextBox>
    <asp:RequiredFieldValidator ID="TextBoxRequiredFieldValidator" runat="server" Display="Dynamic"
    ControlToValidate="RadTextBox1" ErrorMessage="The textbox can not be empty!" />

                        </td>
                    </tr>
                    <tr class="FormContainer">
                        <td>
                            Age:
                        </td>
                        <td>
                            <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" Type="Number" NumberFormat-DecimalDigits="0">
                            </telerik:RadNumericTextBox>
    <asp:RequiredFieldValidator ID="NumercTextBoxRequiredFieldValidator" runat="server"
    Display="Dynamic" ControlToValidate="RadNumericTextBox1" ErrorMessage="Please, select an year number!" />

    <asp:RangeValidator ID="NumericTextBoxRangeValidator" runat="server" ControlToValidate="RadNumericTextBox1"
    ErrorMessage="Year number should be a non negative less than 50." Display="Dynamic"
    MaximumValue="50" MinimumValue="0" Type="Double" />

                        </td>
                    </tr>
                    <tr class="FormContainer">
                        <td valign="top">
                            Phone:
                        </td>
                        <td>
                            <telerik:RadMaskedTextBox ID="RadMaskedTextBox1" runat="server" Mask="(###)-######">
                            </telerik:RadMaskedTextBox>
    <asp:RequiredFieldValidator Display="Dynamic" ID="MaskedTextBoxRequiredFieldValidator"
    runat="server" ErrorMessage="Please, enter a phone number." ControlToValidate="RadMaskedTextBox1"></asp:RequiredFieldValidator>

    <asp:RegularExpressionValidator Display="Dynamic" ID="MaskedTextBoxRegularExpressionValidator"
    runat="server" ErrorMessage="Format is (###)-######" ControlToValidate="RadMaskedTextBox1"
    ValidationExpression="\(\d{3}\)-\d{6}" />

                        </td>
                    </tr>
                    <tr class="FormContainer">
                        <td valign="top">
                            Email
                        </td>
                        <td>
                            <telerik:RadTextBox ID="Radtextbox2" runat="server">
                            </telerik:RadTextBox>
    <asp:RegularExpressionValidator ID="emailValidator" runat="server" Display="Dynamic"
    ErrorMessage="Please, enter valid e-mail address." ValidationExpression="^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"
    ControlToValidate="Radtextbox2">

                            </asp:RegularExpressionValidator>
    <asp:RequiredFieldValidator ID="Requiredfieldvalidator1" runat="server" Display="Dynamic"
    ControlToValidate="Radtextbox2" ErrorMessage="Please, enter an e-mail!" />

                        </td>
                    </tr>
                    <tr class="FormContainer">
                        <td>
                            Hire&nbsp;Date:
                        </td>
                        <td>
                            <telerik:RadDateInput ID="RadDateInput1" Style="font: 8pt monospace" runat="server"
                                DateFormat="d" MinDate="01/01/1990" MaxDate="01/01/3000">
                            </telerik:RadDateInput>
    <asp:RangeValidator ID="DateInputRangeValidator" runat="server" ControlToValidate="RadDateInput1"
    ErrorMessage="Choose a date between 5th of January 2005 and 1st of September 2005"
    Display="Dynamic" MaximumValue="2005-09-01-00-00-00" MinimumValue="2005-01-05-00-00-00" />

    <asp:RequiredFieldValidator ID="PickerRequiredFieldValidator" runat="server" Display="Dynamic"
    ControlToValidate="RadDateInput1" ErrorMessage="Please select a date" />

                        </td>
                    </tr>
                </table>
                <br />
                <br />
    <asp:CheckBox ID="CheckBox1" runat="server" Text="Client Side Validation" Checked="True"
    AutoPostBack="True"></asp:CheckBox>

                <br />
                <br />
                <asp:Button ID="Button1" runat="server" Text="Postback" class="qsfButton"></asp:Button>
                <input type="reset" class="qsfButton" value="Reset" />
            </fieldset>
        </telerik:RadAjaxPanel>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <!-- content end -->
        <qsf:Footer runat="server" ID="Footer1"></qsf:Footer>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451