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

Onkeyup not working for radtextbox

5 Answers 46 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Prateek
Top achievements
Rank 1
Prateek asked on 16 Dec 2016, 01:29 AM
I am using the below radtextbox and the onkeyup is not working for it. Below is the code:
<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

Sort by
0
Vasil
Telerik team
answered on 16 Dec 2016, 02:02 PM
Hi Prateek,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Prateek
Top achievements
Rank 1
answered on 16 Dec 2016, 08:32 PM
There are no javascript errors. If I want to display an error message if the validation on keyup is not successful how can I do that?
0
Vasil
Telerik team
answered on 20 Dec 2016, 07:52 AM
Hi Prateek,

What validator do you use?

Regards,
Vasil
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Prateek
Top achievements
Rank 1
answered on 20 Dec 2016, 05:59 PM

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;
        }
    }

0
Vasil
Telerik team
answered on 23 Dec 2016, 12:14 PM
Hi Prateek,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Prateek
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Prateek
Top achievements
Rank 1
Share this question
or