SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Jul 31, 2002, 04:41 #1
- Join Date
- Jul 2002
- Location
- Birmingham UK
- Posts
- 35
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Using JavaScript to empty a textarea
I've got a textarea with the following content in:
myname@website.com
anothername@website.com
What I want to do is empty the text area when the focus is on it, but only if the value is of that above. If the user has already edited the text area and focuses on it again, it shouldn't empty the area.
Any ideas?
Si
-
Jul 31, 2002, 05:27 #2
- Join Date
- Jul 2002
- Location
- Penns Woods
- Posts
- 44
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Way Cool...
<input type="text" name="T1" size="30" value="myname@website.com" onFocus="if(this.value=='myname@website.com')this.value=''; maxLength="50">
This would be nice on SitePoint's Login... <input type="text" name="T1" size="30" value="Unregistered" onFocus="if(this.value=='Unregistered')this.value=''; maxLength="50">
//PS! My brain just hit a bad sector...
-
Jul 31, 2002, 05:36 #3
- Join Date
- Jul 2002
- Location
- Birmingham UK
- Posts
- 35
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Cheers for that.
I know how to do it with a single line text input (the one you've demonstrated), but I'm having troubles with multi line inputs (ie. textarea).
How do you say if a value = "myname@website.com
anothername@website.com" where there is a carriage return in between the two values?
Any more ideas?
-
Jul 31, 2002, 06:18 #4
- Join Date
- Jul 2002
- Location
- Penns Woods
- Posts
- 44
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Wild Guess...
<input type="text" name="T1" size="30" value="myname@website.com&#13;anothername@website.com" onFocus="if(this.value=='myname@website.com&#13;anothername@website.com')this.value=''; maxLength="50">
//PS! My brain just hit a bad sector...
-
Jul 31, 2002, 08:48 #5
- Join Date
- Jul 2002
- Location
- Penns Woods
- Posts
- 44
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This works...
Sorry,
I didn't pick up on the "textarea", must've been daydreaming...
<html>
<head>
<title>textarea</title>
<script>
function swap(){
set0.style.display='none';
set1.style.display='';
}
</script>
</head>
<body>
<form>
<div id="set0" style="display:''">
<textarea rows="5" cols="30" onFocus="swap()">myname@website.com&#13;anothername@website.com</textarea>
</div>
<div id="set1" style="display:'none'">
<textarea rows="5" cols="30"></textarea>
</div>
</form>
</body>
</html>//PS! My brain just hit a bad sector...
-
Jul 31, 2002, 10:09 #6
Bookmarks