Show error message inside Textbox

2 posts, 1 answers
  1. Saira
    Saira avatar
    24 posts
    Member since:
    Feb 2013

    Posted 12 Mar 2013 Link to this post

    Hello,

    I am developing a web site to target mobile devices and So to save space i want to display error messages inside the Radtextbox if validation fails. Is this possible?

    Thank you,
    Saira
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Mar 2013 Link to this post

    Hello Saira,

    Yes, its possible to display the error messgae inside the RadTextBox. Please have a look into the following code I tried.

    ASPX:
    <telerik:RadTextBox ID="RadTextBox1" runat="server" EmptyMessage="Enter username">
    </telerik:RadTextBox>
    <telerik:RadTextBox ID="RadTextBox2" runat="server" EmptyMessage="Enter password">
    </telerik:RadTextBox>
    <asp:Button ID="Button1" runat="server" Text="PostBack" />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Text="username is required" ControlToValidate="RadTextBox1"
        Style="display: none;"></asp:RequiredFieldValidator>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Text="password is required" ControlToValidate="RadTextBox2"
        Style="display: none;"></asp:RequiredFieldValidator>

    JavaScript:
    <script type="text/javascript">
      ValidationSummaryOnSubmit = function (validationGroup) {
          for (var i = 0; i < Page_Validators.length; i++)
              if (!Page_Validators[i].isvalid) {
                  var textbox = $find(Page_Validators[i].controltovalidate);
                  if (textbox) {
                      textbox.set_textBoxValue(Page_Validators[i].textContent);
                      textbox._invalidate();
                      textbox.updateCssClass();
                  }
              }
        }
     </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top