Solved

alert on textbox focus

Posted on 2007-04-11
5
439 Views
Last Modified: 2012-05-05
i need to have an alert window popup when a user clicks in a textbox on a page.. how do i do this.

0
Comment
Question by:t3ssav
  • 4
5 Comments
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
<input type="text" onclick="javascript:alert('Message');">
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 250 total points
Comment Utility
In your question title you said focus and not click.  In that case:

<input type="text" onfocus="javascript:alert('Message');">

However that will be very annoying.
0
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
<script type="text/javascript">
var messageShown = false;

function focusMessage() {
    if (!messageShown) {
           alert('Message');
           messageShown = true;
    }
}
</script>

<input type="text" onfocus="focusMessage()">

Would be better as it only will show the message once per page load.

0
 

Author Comment

by:t3ssav
Comment Utility
the requirement for the project is that when they focus the text box.. every time they focus it it has to popup a disclaimer...
0
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
Build what they want but I wouldn't be surprised if they later changed their mind.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

772 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

11 Experts available now in Live!

Get 1:1 Help Now