JavaScript function to check if only has digits or decimals in string
<p>I am trying to check to see if my string only have numbers or decimals in it using JavaScript.</p>

<p>If it has only numbers or decimals in the string then it should pass else it want to display a alert saying there is a error.</p>

<p>I have tried using the following code but it doesn't alert anything..</p>

<p>Am I doing something wrong?</p>

<pre><code>var myString = "abc"; 

        if (myString.matches("[0-9].") &amp;&amp; myString.length() &gt; 2) 
        {
            alert("Pass");
        }
        else
        {
            alert("Error");
        }
</code></pre>
