How To Clear Input Field on Focus using JavaScript?

Today, We want to share with you javascript clear input field.In this post we will show you javascript reset input field, hear for how to clears textbox value after submit in html? we will give you demo and example for implement.In this post, we will learn about onchange jquery with an example.

javascript reset input field Example

When the input field gets focus, replace its current value with an empty string.

Read Also:  Remove HTML Table Row and Column using jQuery

<input type="text" onfocus="this.value=''" value="The text">

Example 1: Clears Input Field on Focus

<!DOCTYPE html>
<html>
<body>

<p>javascript clears input field - gets focus:</p>
<input type="text" onfocus="this.value=''" value="Pakainfo">

</body>
</html>

Example 2: Clears Input Field with a Button

<!DOCTYPE html>
<html>
<body>

<p>javascript clear input field on click:</p>
<button onclick="document.getElementById('liveTxt').value = ''">Clears input field</button>

<input type="text" value="Pakainfo" id="liveTxt">

</body>
</html>

I hope you get an idea about jquery reset input value.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  how to get all checked checkbox value in javascript?

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  how to create dynamic calendar in html?
  2. Read Also:  jquery Pass PHP Laravel 5.6 Variables to Javascript
  3. Read Also:  jQuery Save and retrieve Session Variable Value
  4. Read Also:  How to display cross domain json data using Jquery
  5. Read Also:  FontSpace Web Application Icons
  6. Read Also:  Create a Registration and Login System with PHP and MySQL
  7. Read Also:  Check if element Exists on the Page using jQuery
  8. Read Also:  How to reset the text field in a form using javaScript?
  9. Read Also:  Reset input fields using onchange event in JQuery
  10. Read Also:  PHP Google No CAPTCHA reCAPTCHA jQuery Ajax
CLOSEX