Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
msgbox to display a text on input type = text on FOCUS
Old 03-15-2006, 05:34 AM msgbox to display a text on input type = text on FOCUS
Junior Talker

Posts: 3
Trades: 0
Hi,

I dont know how to display a message on focus .HELP?

This is giving a error message and not working.


<script type="text/javascript">
<!--
msg.innerHTML = 'Default text';
//-->
</script>




<input type="text" name="name" size="20"
onfocus="msg.innerHTML='Please write your name here.'"
onblur="msg.innerHTML=''">
ritesh is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-15-2006, 06:30 AM Re: msgbox to display a text on input type = text on FOCUS
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
more a javascript question but;

you are doing things absolutely the wrong way around

the way your code is setup what would happen (if it worked) it would clear the text that the user had just entered when they exited the text field and each time the user clicked into the text box their text would be replaced with the default.

Code:
<input type="text" name="name" id="id" value="Type your name here" onFocus="this.select()">
This would select the existing text in the field
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-18-2006, 02:40 AM Re: msgbox to display a text on input type = text on FOCUS
Super Talker

Posts: 144
Trades: 0
you are looking for something like this??

Code:
<input type="text" name="enter_name" value="enter your name here" onfocus="if (this.value == 'enter your name here') this.value = '';" onblur="if (this.value.trim() == '') this.value = 'enter your name here';">
I used my custom trim() String protocol, so here it is for ya.

Code:
<script language="javascript">
  String.prototype.trim = function() {
    return(this.replace(/(^\s+)|(\s+$)/g, ""));
  }
</script>
__________________
create.vibe

Please login or register to view this content. Registration is FREE
createvibe.com is offline
Reply With Quote
View Public Profile Visit createvibe.com's homepage!
 
Reply     « Reply to msgbox to display a text on input type = text on FOCUS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22351 seconds with 12 queries