Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on 

Clear input text

Hi experts, I want to erase all datas stored in the input text. I am using Firefox browser. Every time I type each input text it will remain even I manually the history of the browser. Help please!

<script>
function Clear()
{
  document.getElementById("email").value = ""; //must erase all stored datas
}
</script>
HTMLJavaScriptASP

Avatar of undefined
Last Comment
Whing Dela Cruz
Avatar of Big Monty
Big Monty
Flag of United States of America image

this should work:

<input type="text" name="email" id="email" onfocus="Clear()" />
Avatar of Big Monty
Big Monty
Flag of United States of America image

this'll clear out the field every time you enter into it
Avatar of Whing Dela Cruz

ASKER

Hi Monty, I will try it more, it seems not working on me..
Avatar of Big Monty
Big Monty
Flag of United States of America image

post your code and I can check
Avatar of Whing Dela Cruz

ASKER

Hi Monty my input text is inside the table, maybe that's the factor. But anyways, i will post my code in a minute.
Avatar of Whing Dela Cruz

ASKER

<!Doctype Html>
<Html>
<body>
   <form name="EnrollForm" method="post" action="Enroll.asp">
       <table id="EnrollTable" class="four">
                  <tr>
                     <td>&nbsp; First Name</td>
                     <td><input type="text" placeholder="First Name" name="cname" required class="i22" id="ccname" maxlength="10" onfocus="Clear()"/></td>
                  </tr>
                  <tr>
                     <td>&nbsp; Last Name</td>
                     <td><input type="text" placeholder="Last Name" name="lname" required class="i22" id="llname" maxlength="12"></td>
                  </tr>
                  <tr>
                     <td>&nbsp; Email</td>
                     <td><input type="email" placeholder="email" id="eml" name="email" required class="i22"></td>
                  </tr>
                  <tr>
                     <td>&nbsp;</td>
                     <td></td>
                  </tr>
                  <tr>
                     <td>&nbsp; Click to Create Account</td>
                     <td><input type="submit" Class="iReg2" value="Create Account" onclick="return ValidateNo()"></td>
                  </tr>

            </Table>

   </form>
</body>
</Html>
Avatar of Big Monty
Big Monty
Flag of United States of America image

in your original question, it looked like you wanted to use a JS function, but there's none in this code :) no problem, just change your field to:

<input type="text" placeholder="First Name" name="cname" required class="i22" id="ccname" maxlength="10" onfocus="this.value = '';"/>
Avatar of Whing Dela Cruz

ASKER

Hi Monty, still not working. I am using Firefox..
Avatar of Whing Dela Cruz

ASKER

I will double check sir, I will feedback you later for any results. Thank you so much!
Avatar of Whing Dela Cruz

ASKER

Hi Monty, sorry for not clarifying my questions. Your solution is answered already to my first problem. It clear the field in every time I click it. My next problem is that the data stored on the memory. I guess its memory within the input text. I want them to clear. I attached here the image of the input text where you can see Erwin, John, Jyle and Pedro. Those are the names stored on the textbox. Can I erase them all?

<script>
function Clear()
{
  document.getElementById("email").value = ""; //must erase all stored datas. please see attached image.
}
</script>
error.bmp
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Whing Dela Cruz

ASKER

Hi Monty its working, Thank you so much!
Avatar of Big Monty
Big Monty
Flag of United States of America image

my pleasure :)
Avatar of Whing Dela Cruz

ASKER

Thanks a lot sir, More power to you and God bless!
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo