javascript parseFloat can't determine if the input is float or not
<p>I am new to javascript and php and programming so pls bear with me.</p>

<p>I am trying to create javascript function to check if the user enters a float value or not. The event is keypressed so it will check every character.</p>

<p>What happens is that if the first character is a float it say its float for the rest of the input even if the following characters are already non numeric. Also if the first character is non numeric it will say not float even if the there are some non numeric characters. It seems to me that it only checks the first character. Pls help...</p>

<p><b><code>index.php</code></b></p>

<pre><code>&lt;script type="text/javascript" src="javascript.js"&gt; &lt;/script&gt;

&lt;form action="index.php" method="get"&gt;
 Integer 1: &lt;input type="text" id="num1" name="num1" onkeypress="checkInput(this);" /&gt; &lt;br /&gt;
 Integer 2: &lt;input type="text" id="num2" name="num2" onkeypress="checkInput(this);" /&gt; &lt;br /&gt;
 &lt;input type="submit" value="Compute" /&gt;
&lt;/form&gt;
</code></pre>

<p><br /></p>

<p><b><code>javascript.js</code></b></p>

<pre><code>function checkInput(obj) {
 if(!parseFloat(obj.value)) {
  alert("Not Float");
 } else {
  alert("Float");
 }
}
</code></pre>
