|
| Web Hosting Deals | Holiday Logo Design | Webcam Chat | Website Header Templates | Register domain | Search Engine Optimisation | Web Hosting |
|
|||||||
| PHP / Perl / Java / JavaScript / CGI Tutorials PHP / Perl / Java / JavaScript / CGI Tutorials Please do not use this Forum to advertise your site or to link to tutorials. |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Clear Text Box
Before I start this nice and simple (but effective code) I would like to
Note: That there is not much to comment on here, as it is kinda self explanatory (I will try to comment it best I can at the end), and you can not (as I know of) use this in like a textarea but only an are such like a Login Box. And We Are Off: Code:
Username: <input size="15" name="login" class="forminputb" onclick="if (this.value == 'Username') { this.value = ''; }" onfocus="if (this.value == 'Username') { this.value = ''; }" onblur="if (this.value == '') { this.value = 'Username'; }" type="username" value="Username" /><br />
To start off We have the word Username: Which says what you input into that box. Then We follow up by making the <input> code which makes the text box to put the info. Next we define how long we want it (size="15") so its 15 pixel long. Then we just give it a name. And then we give it a class to edit it in our css if wanted. Now comes some more advanced stuff which I may not be able to explain to offel well but Ill try. So we start with this. Code:
onclick="if (this.value == 'Username') { this.value = ''; }"
Next we have This: Code:
onfocus="if (this.value == 'Username') { this.value = ''; }"
And now we have This: Code:
onblur="if (this.value == '') { this.value = 'Username'; }"
And now is just some of the easier stuff to explain again: Code:
type="username" value="Username" /> I hope I did this well enough for you to at least understand a little bit. If I didnt you could always just copy and paste it lol. (P.S. = In the Code:
onclick="if (this.value == 'Username') { this.value = ''; }"
|
|
|||
|
not very why? I might be missing some obvious things, but i did as best I could on explaining something I really dont know of what all it means. I did my best, in either which case, just look at it and learn it. Its not to difficult.
|
|
||||
|
you are smart
haha
__________________
http://www.myspace.com/jakeyuan |
|
|||
|
Ok here is a working example of it now. Sorry it took so long, have been busy.
New Website (Still Under Construction Look In The Users Box, Both The Username And Password One Works. P.S.: Wthis Site Is For A Friend. lol |
|
|||
|
Pretty nice but when you click on the username, it clears he, but if I click then directy after I clicked on the username, on the password field, then it only clears the password field and the username field gets filled again
![]() edit: nvm, I see that's also the meaning ![]() Last edited by skyfe; 05-29-2007 at 08:58 AM. |
|
|||
|
ok you had me worried there, but ya thats the point, as long as what you have typed stays in the input field, and when you tab etc... It should be working right, if not let me know on here, and post your code to see If I can help you.
And Why Do People keep saying Im Smart lol, Its kinda basic Javascript. O well i dont mind.
__________________
Friends New Website Im Working on |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|