InputManager with space checking

3 posts, 1 answers
  1. silver chan
    silver chan avatar
    3 posts
    Member since:
    Jan 2010

    Posted 04 Jan 2010 Link to this post

    <telerik:RadInputManager ID="RadInputManager1" runat="server"> 
        <telerik:TextBoxSetting Validation-IsRequired="true">
                            <TargetControls>
                                <telerik:TargetInput ControlID="tb_user_loginname" />
                                <telerik:TargetInput ControlID="tb_user_pass" />
                                <telerik:TargetInput ControlID="tb_user_name" />
                                <telerik:TargetInput ControlID="tb_group_name" />
                            </TargetControls>
         </telerik:TextBoxSetting>
    </telerik:RadInputManager>

    I used the upon code for checking the textbox input, but it have problem when entering a space to the textbox.
    It will pass the checking. Can i checking with the space ?
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jan 2010 Link to this post

    Hello Silver,

    You can prevent the user typing space in the textbox as shown below.

    aspx:
     
    <telerik:RadInputManager ID="RadInputManager1" runat="server"
        <telerik:TextBoxSetting Validation-IsRequired="true"
            <ClientEvents OnKeyPress="OnKeyPress" /> 
            <TargetControls> 
                <telerik:TargetInput ControlID="tb_user_loginname" /> 
                <telerik:TargetInput ControlID="tb_user_pass" /> 
                <telerik:TargetInput ControlID="tb_user_name" /> 
            </TargetControls> 
        </telerik:TextBoxSetting> 
    </telerik:RadInputManager> 
     
    <asp:TextBox ID="tb_user_loginname" runat="server"></asp:TextBox> 
    <asp:TextBox ID="tb_user_pass" runat="server"></asp:TextBox> 
    <asp:TextBox ID="tb_user_name" runat="server"></asp:TextBox> 

    javascript:
     
    <script type="text/javascript"
        function OnKeyPress(sender, args) { 
            if (args.get_keyCode() == 32) { 
                args.set_cancel(true); 
            } 
        } 
    </script> 

    -Shinu.
  3. silver chan
    silver chan avatar
    3 posts
    Member since:
    Jan 2010

    Posted 04 Jan 2010 Link to this post

    Thanks a lot for your help
Back to Top