0

i cant use css validation class inside asp.net controls but all other css design works correctly for example i just need to add class="validate[required]" to make a control validation in html but the same is not working for asp.net textbox controls i tried CssClass too didnt work. please help, thanks in advance

<asp:TextBox ID="txt_uname" runat="server" Height="25" CssClass="validate[required]"></asp:TextBox>

2
  • 1
    please show your code. Commented Jun 6, 2013 at 8:40
  • 1
    validate[required] is not even a proper class name. Commented Jun 6, 2013 at 8:49

1 Answer 1

3
validate[required]

This is not a valid css class name. This declaration means validate class will apply to those elements, which have required attribute.

Your css class

.validate[required]
{
  color:Red;
}

So try this

<asp:TextBox ID="txtUsername" runat="server" CssClass="validate" required="required"></asp:TextBox>
Sign up to request clarification or add additional context in comments.

8 Comments

thanks a lot sachin, m noob in asp you just saved lots of hours of .net validations
what if css class is "validate[required,custom[email]]" ?
@miko1 I wonder where you did get requirements like that from.
@Mr Lister it's from a php project with jquery validation please help how can i make it work in asp 'required' one worked :)
If it's about jQuery, why did you tag your post with css? I'm not sure why you need to use those classes for styling inputs; use a different class for that. By the way, this is the same jQuery library that is mentioned in this question and this one, right?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.