?
Solved

Highlight and Unhighlight Form Field

Posted on 2003-03-17
3
Medium Priority
?
1,030 Views
Last Modified: 2012-08-14
Here is bobbit13's code to highlight the strError:

if(!validateEmailv2(objValue.value))
              {
                if(!strError || strError.length ==0)
                {
                   strError = " Please enter a valid email address. ";
                   objValue.style.background = "#XXXXXX"; // choose color
                }//if                                              
                alert(strError);
                return false;
              }


But I would like the background to change back to #FFFFFF if the strError is corrected.  I suspect the easy way to do this is to change the background back to white when the user clicks on the "ok" button of the alert, or when the user onClicks inside this text field again to correct the problem.  The validation will run again and change the text field back to yellow if still incorrect.

0
Comment
Question by:champ_010
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 400 total points
ID: 8154385
first way (after ok is pressed):

                if(!strError || strError.length ==0)
                {
                   strError = " Please enter a valid email address. ";
                   objValue.style.background = "#XXXXXX"; // choose color
                }//if                                              
                alert(strError);
                objValue.style.background = "#FFFFFF";
                return false;

0
 
LVL 18

Expert Comment

by:bobbit31
ID: 8154410
second way:

  <input type=text onfocus="this.style.background='#FFFFFF';">

or you could do it onchange

  <input type=text onchange="this.style.background='#FFFFFF';">
0
 
LVL 1

Author Comment

by:champ_010
ID: 8154464
Thanks bobbit31,

I like the first way.  I actually tried that before posting, but didn't work--probably because of a typo!--I've done that so many times before, but still haven't learned!  Glad you showed me.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

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