To start with, if you are already using jQuery,
is not needed, as you can use jQuery selectors
Now the solution: text box is actually the
element with the attribute
. For all input elements, its value is accessed through its property
So, apparently, you only need to assign this value to empty string, in the handler of the event you need under condition you need.
However, I would not advise you to do it. Usually, the user knows better what to delete from input data and when. By the user will be only frustrated if the input data is cleaned without her/his order. Maybe the user wants to repeat the same value or modify just one or too characters in it? If I, personally, came across the behavior you describe, I would do all my best to avoid your site. Some of your users might feel the same. Do you need it?—SA