I am trying to check to see if my string only have numbers or decimals in it using JavaScript.
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.
I have tried using the following code but it doesn't alert anything..
Am I doing something wrong?
var myString = "abc";
if (myString.matches("[0-9].") && myString.length() > 2)
{
alert("Pass");
}
else
{
alert("Error");
}