question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clear text on value clear

See original GitHub issue

If the input is cleared using something like: document.getElementById('fileInput').value = ''; The filename stays in place even though the underlying input has been cleared.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
tracerxcommented, Nov 19, 2018

That PR wouldn’t fix this issue because changing the value in the JS won’t fire the change event. As you suggested, a refresh method for the control would be needed. form.reset works but not if you just want to change the value of that control without resetting the rest of the form.

1reaction
Johann-Scommented, Nov 19, 2018

Maybe before the PR of @CometS1, @tracerx you can try something like that:

var fileInput = document.getElementById('fileInput')
fileInput.value = ''
fileInput.dispatchEvent(new Event('change'))

EDIT:

BTW it works pretty well see: https://codepen.io/Johann-S/pen/LXOYbR

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Clear Input Field on Focus
Click on the input field to clear it: Clear Input Field on Focus. Example. <!-- When the input field gets focus, replace its...
Read more >
How to clear textbox value using jQuery
Clear all textbox $(document).ready(function() { $('input[type=text]'). · Clear single textbox value $(document).ready(function() { $('#txtID').
Read more >
Clear text field value in JQuery - javascript
In simple way, you can use the following code to clear all the text field, textarea, dropdown, radio ...
Read more >
HTML | Clearing the input field
To clear the entire input field without having to delete the whole ... "text" onfocus = "this.value=''" value = "Click here to clear"...
Read more >
Proper way to "clear" value from Text input
In Step 2 the user opens the item and "removes" the value they had entered (i.e. they erase the value to represent a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found