Javascript variables
<p>I'm writing a javascript that checks the user input and validates it as a number, and this is my function:</p>

<pre><code>&lt;script type="text/javascript"&gt;
function checkThis(field)
{
    if(isNaN(field.value))
   {
       alert(field.value + ' is an illegal value. Insert a number');
   }
}
&lt;/script&gt;
</code></pre>

<p>Now I want, when the condition is true, restore the last typed value, for example: if the user types <code>123</code>, then the condition is false, but if the user types <code>123a</code> then the condition is true and the alert is triggered. I want, after the alert, the value of the field becomes 123.</p>

<p>This is the code of the field:</p>

<pre><code>&lt;input type="text" onkeyup="checkThis(this)" /&gt;
</code></pre>

<p>Can this be done?</p>
