Hi all!
I have a very simple question but I didn’t find anything on this theme.
How to make a button to clear an input text field from the previously entered text?
I’m feeling helpful today. Here, have a present:
I’ve used an HTML embed. Open up that embed or see below for the code. This Reset button will reset everything within the form - use with caution as it may frustrate your site visitor if they click it by mistake:
Bottom example:
This uses Javascript in the <body>
tag, like so:
Note that the reset
referred to within this code is an actual button element with an id of reset
- it’s not an HTML embed. Further note that the field you want this button to clear needs to have the ID set - in this case the field I want to clear is name-field
, so it has an ID of name-field:
Here’s the working example:
Andy, thank you for your very detailed answer! I’ve just tried — the text input becomes clear. But my problem isn’t solved I want to clean text in the search text field — text is deleted but after that my list doesn’t return to an initial state and doesn’t see that text field is empty
[
Unfortunately I’m not sure how to achieve what you want - hopefully someone with deeper knowledge of the script required will see this and reply!