Solved

How to change the textbox background color when the Regular expression shows an error?Bookmark:Question:

Posted on 2009-04-13
1
215 Views
Last Modified: 2012-05-06
Instead of using the error message "Error" I would like to change the textbox txtzipcode  background red using CSS can this be done.

<form id="form1" runat="server">
    <div>
   
        <asp:TextBox ID="txtzipcode" runat="server"></asp:TextBox>
        <asp:RegularExpressionValidator ID="ValZipcode" runat="server"
            BorderStyle="None" ControlToValidate="txtzipcode"
            ErrorMessage="Error"
           
           
            ValidationExpression="^((\d{5}-\d{4})|(\d{5})|([AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy]\d[A-Za-z]\s?\d[A-Za-z]\d))$"
            ForeColor="#FF3300"></asp:RegularExpressionValidator>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" />
   
    </div>
    </form>
0
Comment
Question by:WDJ98338
1 Comment
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
Comment Utility
Hi WDJ98338,
You can apply the CSS changes whenever errors thrown via customvalidator instead of regularExpressionValidator control. Here is the similiar thread that mentioned same idea:
http://forums.asp.net/t/1335497.aspx

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
Introduction (All good things must come to an end (http://en.wikipedia.org/wiki/All_Good_Things...)) The original MySQL API (http://php.net/manual/en/book.mysql.php) has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all curre…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now