<td align="left" style="Width:80px; padding-bottom:10px;"><telerik:RadTextBox ID="SphereRightText" runat="server" width="50" OnKeyUp="doRightSphereValidation();" onchange="FormatRightSphere(2, true);" /></td>
function doRightSphereValidation()
{
if (IsRightLensItemSelected())
{
var textBox = $find("<%=SphereRightText.ClientID %>");
return validation_ValidateNumericTextBox(textBox, RightSphereMinimum, RightSphereMaximum, false, TurnInvalidInputsRed());
}
else
{
return true;
}
}
5 Answers, 1 is accepted
Please check if you don't have some JavaScript error in your page. I just tested that sample and it works correctly:
<script type=
"text/javascript"
>
function
doRightSphereValidation() {
alert(
"keyup"
);
}
</script>
<telerik:RadTextBox runat=
"server"
onkeyup=
"doRightSphereValidation()"
/>
Regards,
Vasil
Telerik by Progress
What validator do you use?
Regards,
Vasil
Telerik by Progress
I am using custom validators and right now none of them is working. Suddenly none of the custom validators are working for me.
They used to work fine but have stopped working now. Below is one of the example :
<td align="left"><telerik:RadTextBox ID="NearPDRightText" runat="server" width="50" OnKeyUp="doRightNearPDValidation()" onchange="FormatRightNearPD(1, false)" CssClass="RequiredField"/></td>
<td><asp:CustomValidator ValidationGroup="EyeglassOrderLensesGroup" ID="cvNearPDRight" Display="Dynamic" CssClass="Error" runat="server" ClientValidationFunction="ValidateRightNearPD" ></asp:CustomValidator></td>
function ValidateRightNearPD(source, args)
{
args.IsValid = doRightNearPDValidation();
}
function doRightNearPDValidationSub()
{
if (IsRightLensItemSelected())
{
var textBox = $find("<%=NearPDRightText.ClientID %>");
return doPDValidationSub(textBox);
}
else
{
return true;
}
}
The code of the validator seems to be correct, and it executes if there is value in the input. Note that CustomValidator only executes if the value is not empty string. This is the reason it is generally used in combination with RequiredFieldValidator.
The doRightNearPDValidation function that you call on keyup event is not specified in your code, and I would assume that it does not actual trigger the validator since you call it in the ValidateRightNearPD as well.
If it was made to trigger the page validation, then the code would have hang in endless recursive loop.
If you only check the value in doRightNearPDValidation and return true or false, depending on the value, then it is expected for it not to show error message, since it does nothing called this way.
I would suggest you to change the logic to something like:
onkeyup="Page_ClientValidate()"
for your page.
Regards,
Vasil
Telerik by Progress