3 Answers, 1 is accepted
0
Accepted
Shinu
Top achievements
Rank 2
answered on 12 Mar 2013, 08:40 AM
Hello Saira,
Yes, its possible to display the error messgae inside the RadTextBox. Please have a look into the following code I tried.
ASPX:
JavaScript:
Thanks,
Shinu.
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.
0
Rob Ainscough
Top achievements
Rank 1
answered on 03 Oct 2018, 09:07 PM
I know this is old, but this code doesn't appear to work, nothing happens. I also tried this code here: https://docs.telerik.com/devtools/aspnet-ajax/controls/textbox/features/validation and same result, nothing happens.
Is there something else not mentioned that needs to be included for this to work?
Cheers, Rob.
0
Hello Rob,
Regards,
Marin Bratanov
Progress Telerik
I created a KB article for you with an improved version of the code: https://www.telerik.com/support/kb/aspnet-ajax/textbox/details/how-to-display-errormessage-inside-radtextbox. I suspect that your original issue stems from the Unobtrusive validation that needs to be disabled for this hack to have a chance.
Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.