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

How do I check RadInputManager valid on client side only?

1 Answer 25 Views
Input
This is a migrated thread and some comments may be shown as answers.
Eran
Top achievements
Rank 1
Eran asked on 14 Aug 2013, 10:29 PM
Hi there ,
I have a page with client side code only.
On a button click (using javascript) I want to check if inputs are valid , and if so , execute the javascript (in my case , changing tab on form)
How can I do it?

<asp:TextBox ID="tbFirstName" runat="server" Font-Size="1em" style="width: 150px;" ></asp:TextBox>
 
<telerik:RadInputManager ID="RadInputManager1" runat="server" Skin="Office2007" >
     <telerik:TextBoxSetting BehaviorID="TextBoxBehavior1" EmptyMessage=""  Validation-IsRequired="true" >
         <TargetControls>
             <telerik:TargetInput ControlID="tbFirstName" />
         </TargetControls>
         <ClientEvents OnValidating="onValidating" />
     </telerik:TextBoxSetting>       
</telerik:RadInputManager>

And this is the javascript I want to run in case the input is valid (while clicking on button)

function GeneralContinue() {
    tabStrip = $find('RadTabStrip1');
    tabStrip.findTabByValue('General').select();
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 16 Aug 2013, 05:57 AM
Hi Eran,

Please try the following code snippet that I have tried for checking RadInputManager validation in Client Side.

ASPX:
<asp:TextBox ID="tbFirstName" runat="server" Font-Size="1em" Style="width: 150px;"></asp:TextBox>
<telerik:RadInputManager ID="RadInputManager1" runat="server" Skin="Office2007">
    <telerik:TextBoxSetting BehaviorID="TextBoxBehavior1" EmptyMessage="" Validation-IsRequired="true">
        <TargetControls>
            <telerik:TargetInput ControlID="tbFirstName" />
        </TargetControls>
        <ClientEvents OnValidating="onValidating" />
    </telerik:TextBoxSetting>
</telerik:RadInputManager>
<telerik:RadButton ID="RadButton1" runat="server" Text="Validation" OnClientClicked="OnClientClicked1">
</telerik:RadButton>

JavaScript:
<script type="text/javascript">
    var isvalid = 0; //for validation setting a Global Variable.
    function onValidating(sender, args) {
        var textbox = document.getElementById("tbFirstName");
        if (textbox.value == "") { // your Condition
            //Your Code
        }
        else {
            isvalid = 1; // if validation succeed,setting the global variable.
        }
    }
    function OnClientClicked1(sender, args) {
        if (isvalid == 1) { // The click event will fire only when the global variable is 1.
            alert("fired");
        }
    }
</script>

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