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 Q1 2012 released 04/11/2012
select

Input / HTML5 Support

Example Configuration

Rooms Reservation Form







  • As of Q3 2011 RadTextBox provides support for the new HTML5 input types. To leverage this functionality you can use the InputType property of the control.

    You can set to the following values:
    • Text - RadTextBox renders an input of type text and allows entering any type of string.
    • Number - RadTextBox renders an input of type number and only numbers are recognized as valid entry.
    • Date - RadTextBox renders an input of type date and lets the user enter only dates.
    • Time - RadTextBox renders an input of type time and lets the user enter only time.
    • DateTime - RadTextBox renders an input of type datetime and allows for specifying the time part of the DateTime object.

    Note that not all browsers support HTML5 input types. Those which do not recognize the new input types currently behave as if the input is with type set to text.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" CodeFile="DefaultCS.aspx.cs" AutoEventWireup="false" Inherits="Telerik.InputExamplesCS.Common.HTML5Support.DefaultCS" %>

    <%@ 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 -->
        <style type="text/css">
            .divLeft
            {
                float: left;
                width: 550px;
                line-height: 25px;
            }
            .divRight
            {
                float: left;
                line-height: 25px;
            }
            .divBottom
            {
                width: 250px;
                text-align: right;
            }
        </style>
        <!-- end of custom head section -->
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <qsf:Header runat="server" ID="Header1" NavigationLanguage="C#"></qsf:Header>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
            <!--
                function validateFunction(sender, eventArgs) {
                    eventArgs.IsValid = true;
                    var firstPicker = $find("<%= RadTextBox3.ClientID %>");
                    var secondPicker = $find("<%= RadTextBox4.ClientID %>");
                    if (secondPicker.get_value() <= firstPicker.get_value()) {
                        eventArgs.IsValid = false;
                    }
                }
                function PreviewButtonClick() {
                    if (Page_ClientValidate()) {
                        var resultsDiv = $get("divPreviewResults");
                        resultsDiv.innerHTML = "<h4>You entered the following values:</h4>";
                        resultsDiv.innerHTML += "Your Name: <b>" + $find("<%= RadTextBox1.ClientID %>").get_value() + "</b><br />";
                        resultsDiv.innerHTML += "Number of Rooms: <b>" + $find("<%= RadTextBox2.ClientID %>").get_value() + "</b><br />";
                        resultsDiv.innerHTML += "Check-in Date: <b>" + $find("<%= RadTextBox3.ClientID %>").get_value() + "</b><br />";
                        resultsDiv.innerHTML += "Check-out Time: <b>" + $find("<%= RadTextBox4.ClientID %>").get_value() + "</b><br />";
                    }
                    else {
                        alert("Please fill in the form with valid data!");
                    }
                }
                -->
            </script>
        </telerik:RadCodeBlock>
        <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Expanded="true">
    <asp:CheckBox ID="CheckBox1" runat="server" Checked="true" AutoPostBack="true" Text="Enable Single Input Rendering Mode"
    OnCheckedChanged="CheckBox1_CheckedChanged" />

        </qsf:ConfiguratorPanel>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div class="divLeft">
                    <h4>
                        Rooms Reservation Form</h4>
                    <telerik:RadTextBox ID="RadTextBox1" runat="server" InputType="Text" Label="Your Name: "
                        Width="260px" EnableSingleInputRendering="true">
                    </telerik:RadTextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Name Required!"
    ControlToValidate="RadTextBox1" Display="Dynamic">

                    </asp:RequiredFieldValidator>
                    <br />
                    <telerik:RadTextBox ID="RadTextBox2" runat="server" InputType="Number" Label="Number of Rooms: "
                        Width="260px" EnableSingleInputRendering="true">
                    </telerik:RadTextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="* Number of Rooms Required!"
    ControlToValidate="RadTextBox2" Display="Dynamic">

                    </asp:RequiredFieldValidator>
                    <br />
                    <telerik:RadTextBox ID="RadTextBox3" runat="server" InputType="Date" Label="Check-in Date: "
                        Width="260px" EnableSingleInputRendering="true">
                    </telerik:RadTextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="* Check-in Date Required!"
    ControlToValidate="RadTextBox3" Display="Dynamic">

                    </asp:RequiredFieldValidator>
                    <br />
                    <telerik:RadTextBox ID="RadTextBox4" runat="server" InputType="Time" Label="Check-out Time: "
                        Width="260px" EnableSingleInputRendering="true">
                    </telerik:RadTextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="* Check-out Time Required!"
    ControlToValidate="RadTextBox4" Display="Dynamic">

                    </asp:RequiredFieldValidator>
    <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="* Check-out Time should be later than Check-in Date!"
    Display="Dynamic" ControlToValidate="RadTextBox4" ClientValidationFunction="validateFunction"></asp:CustomValidator>

                </div>
                <asp:Panel CssClass="divRight" ID="divPreviewResults" runat="server">
                </asp:Panel>
                <div style="clear: both">
                </div>
                <br />
                <br />
                <div class="divBottom">
                    <asp:Button ID="Button1" runat="server" Text="Preview" OnClientClick="PreviewButtonClick(); return false;" />
                    <asp:Button ID="Button2" runat="server" Text="Submit" OnClick="Button2_Click" />
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="CheckBox1" />
                <asp:PostBackTrigger ControlID="Button2" />
            </Triggers>
        </asp:UpdatePanel>
        <!-- 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-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451