you should use the setTimeout and clearTimeout functions. lol! jk. u really do need to use them though. i made an example for you
And then add the html button looking like this:
<form name="form_1" method="post">
<input type="text" name="the_text"><br /><br />
<input type="button" onClick="timer();"><br />
<input type="button" onClick="clearIt();">
</form>