Hi.
I'm using RadInputManager to Validate my Controls .
But now I have a problem , I'm gonna use radinputmanager to validate a textbox width specific javascript method . I wrote the below code, but my button do post back . I want to stop post back before validating the textbox .
How can I do this ?
I'm using RadInputManager to Validate my Controls .
But now I have a problem , I'm gonna use radinputmanager to validate a textbox width specific javascript method . I wrote the below code, but my button do post back . I want to stop post back before validating the textbox .
How can I do this ?
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> <script type="text/javascript"> function onValidating(sender, args) { var nationalCode = $get(sender.get_targetControlIDs()[0]); console.log(nationalCode.value); if (!checkCodeMeli(nationalCode.value)) { alert('the code is wrong'); nationalCode.focus(); return false; } else { alert('The code is write ') return true; } } function pageLoad() { window.$ = jQuery = $telerik.$; }function checkCodeMeli(code) { var L = code.length; if (L < 8 || parseInt(code, 10) == 0) return false; code = ('0000' + code).substr(L + 4 - 10); if (parseInt(code.substr(3, 6), 10) == 0) return false; var c = parseInt(code.substr(9, 1), 10); var s = 0; for (var i = 0; i < 9; i++) s += parseInt(code.substr(i, 1), 10) * (10 - i); s = s % 11; return (s < 2 && c == s) || (s >= 2 && c == (11 - s)); return true;} </script> </telerik:RadScriptBlock> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="btn" runat="server" /> <telerik:RadInputManager ID="RadInputManager1" runat="server"> <telerik:TextBoxSetting InitializeOnClient="true"> <TargetControls> <telerik:TargetInput ControlID="TextBox1" /> </TargetControls> <ClientEvents OnValidating="onValidating" /> </telerik:TextBoxSetting> </telerik:RadInputManager>