?
Solved

alert on textbox focus

Posted on 2007-04-11
5
Medium Priority
?
448 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
[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
  • 4
5 Comments
 
LVL 29

Expert Comment

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

Accepted Solution

by:
rdivilbiss earned 1000 total points
ID: 18891688
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
ID: 18891707
<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
ID: 18891805
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
ID: 18892590
Build what they want but I wouldn't be surprised if they later changed their mind.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to count occurrences of each item in an array.
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…
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