How to cancel Remote validation in RadInputManager in OnValidating event?

6 posts, 0 answers
  1. jack
    jack avatar
    5 posts
    Member since:
    Nov 2014

    Posted 23 Aug Link to this post

    I have RadInoutManager for validation in my page . one of them validate from web service and works good but i want to cancel remote validation in TextBox is empty ! I have no problme with validation RadInputManager , just if TextBox is empty so validation for call web service will be canceled until TextBox has a value .

    After search i find OnValidating event . that resaid before client and server side validation in RadInputManger so i can write code here but not working and i can't cancel call w

    <body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
        <telerik:RadInputManager ID="RadInputManager1" runat="server">
            <telerik:RegExpTextBoxSetting BehaviorID="ProvinceCode" ValidationExpression="^\d{1-10}$" FocusedCssClass="center" HoveredCssClass="center" InvalidCssClass="center" ReadOnlyCssClass="center" EnabledCssClass="center" EmptyMessageCssClass="center" DisabledCssClass="center">
                <TargetControls>
                    <telerik:TargetInput ControlID="txtProvinceCode" />
                </TargetControls>
                <Validation ValidateOnEvent="Blur" Method="Find" Location="../../Services/ProvinceService.asmx" ValidationGroup="vgProvince" />
                <ClientEvents OnValidating="RequireProvinceCode"></ClientEvents>
            </telerik:RegExpTextBoxSetting>
        </telerik:RadInputManager>
        <div>
            <label>ProvinceCode</label>
            <asp:TextBox ID="txtProvinceCode" runat="server"></asp:TextBox>
     
        </div>
     
        <div>
            <telerik:RadButton ID="btnSave" runat="server" Text="Save" AutoPostBack="False" ></telerik:RadButton>
        </div>
    </form>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script>
     
            function RequireProvinceCode(sender, args) {
                var inputManager = $find("<%= RadInputManager1.ClientID %>");
                var input = inputManager.get_targetInput("<%= txtProvinceCode.ClientID %>");
                var val = Number(input.get_value());
                console.log(val);
     
                //args.IsValid = false;
                //return false;
            }
     
        </script>
    </telerik:RadCodeBlock>
    eb service . I can check value od TextBox in OnValidating event but i can't cancel remote validation . please help me .

    I have RadInoutManager for validation in my page . one of them validate from web service and works good but i want to cancel remote validation in TextBox is empty ! I have no problme with validation RadInputManager , just if TextBox is empty so validation for call web service will be canceled until TextBox has a value . After search i find OnValidating event . that resaid before client and server side validation in RadInputManger so i can write code here but not working and i can't cancel call web service . I can check value od TextBox in OnValidating event but i can't cancel remote validation . please help me .

    <body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:

    I have RadInoutManager for validation in my page . one of them validate from web service and works good but i want to cancel remote validation in TextBox is empty ! I have no problme with validation RadInputManager , just if TextBox is empty so validation for call web service will be canceled until TextBox has a value . After search i find OnValidating event . that resaid before client and server side validation in RadInputManger so i can write code here but not working and i can't cancel call web service . I can check value od TextBox in OnValidating event but i can't cancel remote validation . please help me .

    <body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:

    I have RadInoutManager for validation in my page . one of them validate from web service and works good but i want to cancel remote validation in TextBox is empty ! I have no problme with validation RadInputManager , just if TextBox is empty so validation for call web service will be canceled until TextBox has a value . After search i find OnValidating event . that resaid before client and server side validation in RadInputManger so i can write code here but not working and i can't cancel call web service . I can check value od TextBox in OnValidating event but i can't cancel remote validation . please help me .

    <body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:

    I have RadInoutManager for validation in my page . one of them validate from web service and works good but i want to cancel remote validation in TextBox is empty ! I have no problme with validation RadInputManager , just if TextBox is empty so validation for call web service will be canceled until TextBox has a value . After search i find OnValidating event . that resaid before client and server side validation in RadInputManger so i can write code here but not working and i can't cancel call web service . I can check value od TextBox in OnValidating event but i can't cancel remote validation . please help me .

    <body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:

    I have RadInoutManager for validation in my page . one of them validate from web service and works good but i want to cancel remote validation in TextBox is empty ! I have no problme with validation RadInputManager , just if TextBox is empty so validation for call web service will be canceled until TextBox has a value . After search i find OnValidating event . that resaid before client and server side validation in RadInputManger so i can write code here but not working and i can't cancel call web service . I can check value od TextBox in OnValidating event but i can't cancel remote validation . please help me .

    <body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:

    I have RadInoutManager for validation in my page . one of them validate from web service and works good but i want to cancel remote validation in TextBox is empty ! I have no problme with validation RadInputManager , just if TextBox is empty so validation for call web service will be canceled until TextBox has a value . After search i find OnValidating event . that resaid before client and server side validation in RadInputManger so i can write code here but not working and i can't cancel call web service . I can check value od TextBox in OnValidating event but i can't cancel remote validation . please help me .

    <body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 25 Aug Link to this post

    Hi Jack,

    You can specify the field as required. This will fire validation only when there is a value entered in the TextBox. For this you just need to set the IsRequired property in Validation to true.


    <telerik:RadInputManager ID="RadInputManager1" runat="server">
        <telerik:RegExpTextBoxSetting BehaviorID="ProvinceCode" ValidationExpression="^\d{1-10}$" FocusedCssClass="center" HoveredCssClass="center" InvalidCssClass="center" ReadOnlyCssClass="center" EnabledCssClass="center" EmptyMessageCssClass="center" DisabledCssClass="center">
            <TargetControls>
                <telerik:TargetInput ControlID="txtProvinceCode" />
            </TargetControls>
            <Validation IsRequired="true" ValidateOnEvent="Blur" Method="Find" Location="../../Services/ProvinceService.asmx" ValidationGroup="vgProvince" />
            <ClientEvents OnValidating="RequireProvinceCode"></ClientEvents>
        </telerik:RegExpTextBoxSetting>
    </telerik:RadInputManager>


    Regards,
    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jack
    jack avatar
    5 posts
    Member since:
    Nov 2014

    Posted 25 Aug in reply to Viktor Tachev Link to this post

    Hi

    I use  IsRequired="true"  but not working and also call web service with empty parameter .

    How can i cancel remote validation in OnValidating event ?

  5. jack
    jack avatar
    5 posts
    Member since:
    Nov 2014

    Posted 25 Aug Link to this post

    Hi
    I use  IsRequired="True" and also Validation-IsRequired="true" but not working for me .
    please help me to solve it .


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <Scripts>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
                    <asp:ScriptReference Path="Scripts/WebForms/WebForms.js"></asp:ScriptReference>
                    <asp:ScriptReference Path="Scripts/WebForms/WebUIValidation.js"></asp:ScriptReference>
                </Scripts>
            </telerik:RadScriptManager>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            </telerik:RadAjaxManager>
            <telerik:RadInputManager ID="RadInputManager1" runat="server" ValidateRequestMode="Enabled">
                <telerik:NumericTextBoxSetting BehaviorID="ProvinceCode" Validation-IsRequired="true" FocusedCssClass="center" HoveredCssClass="center" InvalidCssClass="center" ReadOnlyCssClass="center" EnabledCssClass="center" EmptyMessageCssClass="center" DisabledCssClass="center" DecimalDigits="0" ClearValueOnError="False" SelectionOnFocus="SelectAll" >
                    <TargetControls>
                        <telerik:TargetInput ControlID="txtProvinceCode" />
                    </TargetControls>
                    <Validation IsRequired="True" Method="Find" Location="ProvinceService.asmx" ValidationGroup="vgProvince" />
                    <ClientEvents OnError="onClientDateTxtError" OnKeyPress="onClientTextChanged" OnBlur="onClientTxtBlur"></ClientEvents>
                </telerik:NumericTextBoxSetting>
            </telerik:RadInputManager>
            <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server"
                Position="MiddleRight"
                RelativeTo="Element"
                AutoTooltipify="false"
                Animation="Fade"
                ShowEvent="FromCode"
                HideEvent="FromCode">
            </telerik:RadToolTipManager>
            <div>
                <label>Province Code</label>
                <asp:TextBox ID="txtProvinceCode" runat="server"></asp:TextBox>

            </div>
            <telerik:RadButton ID="RadButton1" ValidationGroup="vgProvince" runat="server" Text="RadButton" OnClientClicked="StandardConfirm"></telerik:RadButton>
            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                <script>

                    var errorCount = 0;
                    var tooltipManager = null;

                    function onValidating(sender, args) {
                        var inputManager = $find("<%= RadInputManager1.ClientID %>");
                        var input = inputManager.get_targetInput("<%= txtProvinceCode.ClientID %>");
                        var val = input.get_value();

                    }

                    function StandardConfirm(sender, args) {
                        var validated = Page_ClientValidate('vgProvince');
                        alert(validated);
                        if (!validated) {
                            args.set_cancel(true);
                            return;
                        }
                    }

                    function onClientDateTxtError(sender, args) {
                        var eleId = args.get_targetInput().get_id();
                        var ele = $get(eleId);

                        var inputManager = $find("<%= RadInputManager1.ClientID %>");
                        var input = inputManager.get_targetInput("<%= txtProvinceCode.ClientID %>");
                        var val = input.get_value();
                        errMsg = String.format("Number {0} is invalid", val);
                        showErrorTip(ele, errMsg);
                    }

                    function showErrorTip(element, msg) {
                        if (tooltipManager == null)
                            tooltipManager = $find("<%= RadToolTipManager1.ClientID %>");
                        if (!tooltipManager) return;
                        var tooltip = tooltipManager.getToolTipByElement(element);
                        if (!tooltip)
                            tooltip = tooltipManager.createToolTip(element);
                        tooltip.set_content(msg);
                        tooltip.set_autoCloseDelay(5000);
                        tooltip.set_manualClose(false);
                        tooltip.show();
                    }
                    function onClientTxtBlur(sender, args) {
                        errorCount = 0;
                    }
                    function onClientTextChanged(sender, args) {
                        HideTooltip();
                    }
                    function HideTooltip() {
                        var tip = Telerik.Web.UI.RadToolTip.getCurrent();
                        if (tip) tip.hide();
                    }
                </script>
            </telerik:RadCodeBlock>
        </form>
    </body>
    </html>

     


  6. jack
    jack avatar
    5 posts
    Member since:
    Nov 2014

    Posted 25 Aug in reply to Viktor Tachev Link to this post

    Hi Viktor
    I use IsRequired="true"  but still call web service with empty parameter when Blur event resaid .
    How can is prevent from call web service when TextBox is empty ?

    Thanks .

  7. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 29 Aug Link to this post

    Hi Jack,

    You can set the state as invalid in the OnValidating event. This way the service should not be called.

    function onValidating(sender, args) {
        if (args.get_input().get_value() == "") {
            args.set_isValid(false);
        }  
    }


    Regards,
    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017