tags:

views:

48

answers:

2

I want to validate an asp.net texbox with min char=3, max=10 and no special characters. I do not want to use a plugin of jQuery but plain jQuery

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

How do I about it.

P.S - I asked the question earlier then edited it, but can't find the question now. Seems like it did not get posted.

+1  A: 

In asp.net you can use the validate control. Either a custom validator or a reg ex validator.

Something like this

<asp:RegularExpressionValidator ID="RegularExpressionValidatorEmail" runat="server"
        ControlToValidate="TextBox1" ErrorMessage="Error error..."
        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Static" ></asp:RegularExpressionValidator>
Richard L
I want to use jQuery and do it
+1  A: 

Why not use a RegularExpressionValidator with the Regex pattern "[\w]{3, 10}" ?

Cerebrus
I want to use jQuery and do it
But why, if I may ask? They both are an abstraction of basic Javascript.
Cerebrus