I have this INPUT, it will clear everytime we click inside of it.
The problem: I want to clear only if value = [email protected]
<script type="text/javascript">     function clearThis(target) {         target.value= "";     } </script> <input type="text" name="email" value="[email protected]" size="30" onfocus="clearThis(this)">   Can someone help me to do this? I don't know how to compare, I already tried but no success.
To clear all the input in an HTML form, use the <input> tag with the type attribute as reset.
Reset or clear a form using JavaScript, with the reset() method. The reset method sets the values of all elements in a form like clicking the reset button.
<script type="text/javascript">     function clearThis(target) {         if (target.value == '[email protected]') {             target.value = "";         }     } </script>  Is this really what your looking for?
For me this is the best way:
<form id="myForm">   First name: <input type="text" name="fname" value="Demo"><br>   Last name: <input type="text" name="lname"><br><br>   <input type="button" onclick="myFunction()" value="Reset form"> </form>       <script> function myFunction() {     document.getElementById("myForm").reset(); } </script>  If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With