Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

JavaScript - how to clear input field on focus or on click?

Ads
destroyer Offline referral

Posts: 430
Joined: Jul 2013
Reputation: 3

#1
Senior Member
Hi I am using a script that counts characters and I want to clear that input field how to do that with onclick or on focus? I don't want to use jQuery but rather JavaScript !
chod Offline referral

Posts: 860
Joined: Jul 2013
Reputation: 85

#2
Posting Freak
Why not share what code you have already first so someone can properly give the functionality that you want. Instead of guessing how you are achieving what you said the code is already doing.

I don't get why you wouldn't even post the relevant code in your post. You should start asking complete and thought out questions so others can give you proper help and not waste their time in doing so.

But here is a freebie
Code:
var form = document.getElementById("myForm");
form.reset();

Next time please step up your level of question and don't make us guess what you have and expect the proper example to be given.
www.AdminEmpire.com
www.BlimptonTech.com - Best Free Online JavaScript tool to minify JavaScript files.
destroyer Offline referral

Posts: 430
Joined: Jul 2013
Reputation: 3

#3
Senior Member
I don't want to share my code that the whole point I don't want anyone to copy it Wink
Code:
<input name="CharacterCount" size="9" maxlength="10">

I want to clear this input field!
chod Offline referral

Posts: 860
Joined: Jul 2013
Reputation: 85

#4
Posting Freak
Then my example is good enough to figure it out on your own. Or wait for others to post
www.AdminEmpire.com
www.BlimptonTech.com - Best Free Online JavaScript tool to minify JavaScript files.
destroyer Offline referral

Posts: 430
Joined: Jul 2013
Reputation: 3

#5
Senior Member
Hold on please I am sorry if you get offended man, listen do I have to add your code into script that counts characters?
chod Offline referral

Posts: 860
Joined: Jul 2013
Reputation: 85

#6
Posting Freak
(11-09-2013 09:45 PM)destroyer Wrote:  Hold on please I am sorry if you get offended man, listen do I have to add your code into script that counts characters?
Sorry I refuse to spoon feed anyone, especially when you state you're too lazy to do your own research.
www.AdminEmpire.com
www.BlimptonTech.com - Best Free Online JavaScript tool to minify JavaScript files.
destroyer Offline referral

Posts: 430
Joined: Jul 2013
Reputation: 3

#7
Senior Member
I told you already it was just a joke comment!
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#8
Support Team
Use this one

PHP Code:
<html>
<
body>
<
script language="JavaScript">
 function 
resetForm(){
   
document.getElementById("myForm").reset();
 } 
</script>
<center>
    <form id="myForm" >
    <input type="text" />
    <br/>
    <input type="button" value="Reset" onClick="resetForm()"/>
    </form>
    </div>
 </center>
</body>
</html> 
maya Offline referral

Posts: 1,058
Joined: May 2013
Reputation: 34

#9
Posting Freak
You don't really need any JavaScript for that just use placeholder and onfocus
PHP Code:
<input type="text" placeholder="Username" onfocus="this.value='';" /> 

Replace Username with what ever text you wish!!





User(s) browsing this thread: 1 Guest(s)