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 that i m not allowed to enter numbers in textbox as keyPress Event of VB.Net..

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...

oks first let me try..then i ask if any probs still there

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

:)

U r making joke of me frnd

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.

hey just kidding, i have the same reputation just like you..

or inch or pinch....

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 :)

Yes we have the same reputation. frnd..both red..red..

so your problem solved.....so i suggest something...?

No probs..I dont mind it....

well that was pretty quick reply...okey time to go GN :)

Reply to PM dat i send u..

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.