This is a migrated thread and some comments may be shown as answers.

Alerting the error messages.

1 Answer 25 Views
Input
This is a migrated thread and some comments may be shown as answers.
Ivy
Top achievements
Rank 1
Ivy asked on 24 Jul 2013, 02:27 AM
Hi 

There are few input fields and required field validators and I tried to display the error message inside the control which is not completely possible due to browser related issues. So I thought of alerting the error messages on validation failed. But how can I get the error messages in javascript so that I can display them in an alert box? Is this a possible requirement?

Thanks
Ivy

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 24 Jul 2013, 04:37 AM
Hi Ivy,

The ASP ValidationSummary has a ShowMessageBox property which you can set to true in order to achieve your requirement. If the ShowMessageBox property is set to true then all the Error Messages are displayed in a browser alert box. Please have a look into the sample code I tried which works fine at my end.

ASPX:
<telerik:RadTextBox ID="RadTextBoxFirstName" runat="server" EmptyMessage="First Name" />
<br />
<br />
<telerik:RadTextBox ID="RadTextBoxLastName" runat="server" EmptyMessage="Last Name" />
<br />
<br />
<telerik:RadTextBox ID="RadTextBoxEmailid" runat="server" EmptyMessage="Email-ID" /><br />
<br />
<telerik:RadButton ID="RadButton1" runat="server" Text="Send" CausesValidation="true"
    ValidationGroup="ValidationGroup1">
</telerik:RadButton>
<asp:RequiredFieldValidator ID="RequiredFirstName" runat="server" ErrorMessage="Full Name is mandatory!"
    ControlToValidate="RadTextBoxFirstName" Display="None" ValidationGroup="ValidationGroup1"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredLastname" runat="server" ErrorMessage="Last Name is mandatory!"
    ControlToValidate="RadTextBoxLastName" Display="None" ValidationGroup="ValidationGroup1"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredEmailid" runat="server" ErrorMessage="Email-ID is mandatory!"
    ControlToValidate="RadTextBoxEmailid" Display="None" ValidationGroup="ValidationGroup1"></asp:RequiredFieldValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="false"
    ShowMessageBox="true" HeaderText="Missing Fields" ValidationGroup="ValidationGroup1"
    DisplayMode="BulletList" />

Thanks,
Shinu.
Tags
Input
Asked by
Ivy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or