Solved

alert on textbox focus

Posted on 2007-04-11
5
445 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
ID: 18891674
<input type="text" onclick="javascript:alert('Message');">
0
 
LVL 29

Accepted Solution

by:
rdivilbiss earned 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

749 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