I want to enter only characters in textbox not numbers.For dat I use Regular Expression Validator,But even after dat numbers are entering.

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
                     <asp:RegularExpressionValidator ID="regexpName" runat="server"     
                                    ErrorMessage="This expression does not validate." 
                                    ControlToValidate="TextBox1"     
                                    ValidationExpression="^[a-zA-Z'.\s]{1,40}$" />

I m take the help from the below site
http://msdn.microsoft.com/en-us/library/ms998267.aspx#paght000001_usingaregularexpressionvalidatorcontrol

tell me one ting more frnds,we have grab the ValidationExpression or there is any logic behind it,I m just grabbing it.

That validation happens server side so you can enter any data you want but on the postback it will fire off and invalidate the data. Is that what you were asking?

You should be able to use "^[a-zA-Z\s]*$" to match only characters and white space

hi there again....check the solution at VBforums....

and please mark me...correct if you problem sorts out...

hi sknake, i m still allowed to enter numbers..

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
                     <asp:RegularExpressionValidator ID="regexpName" runat="server"     
                                    ErrorMessage="This expression does not validate." 
                                    ControlToValidate="TextBox1"     
                                    ValidationExpression="^[a-zA-Z\s]*$" />

Do i have to change textbox properties..

I want the code similar to dat

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57 Then
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

I want the code similar to dat

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57 Then
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

so you want to help or...you'll handle things by your self...

well you have nice reputation on this forum....

:)

U r making joke of me frnd

There is no point in mocking each other, you are both on same boat for similar reasons. So better to do something about it...

Also take it as friendly warning against flaming-wars.

There is no point in mocking each other, you are both on same boat for similar reasons. So better to do something about it...

Also take it as friendly warning against flaming-wars.

yes sir, i i sir :)

hey frnds tell me one thing,did anybody see keyup,keydown or keypress events on textbox(server side)..Suppose we take the eg of yahoo.,In field password,there is restriction special chars are not allwed..but when we enter it,we are allowed to enter it,when we click on submit button,then msg is dere special chars are not allowed....Tel me its poss to have these events use with server side validation(textbox)...

As far as client side validation,I m succeed in doing dat-

<title>Untitled Page</title>
    
     <script type ="text/javascript" language ="javascript">
         function isNumeric(keyCode)
        {
     return ((keyCode >= 48 && keyCode <= 57) || keyCode == 8)
        }

     </script>
     
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
        <table>
            <tr>
                <td style="width: 100px">
                    </td>
                  <input id="Text1" type="text" language="javascript"  onkeydown = "return isNumeric(event.keyCode);" onpaste = "return false;" />
                <td style="width: 100px">
                </td>
                <td style="width: 100px">
                </td>
            </tr>
                    </table>
    </form>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.