Edit in JSFiddle

function IsDecimal(event, obj) {
    var chCode = ('charCode' in event) ? event.charCode : event.keyCode;

    if (chCode >= 48 && chCode <= 57)

    {

        return true;

    } else if (chCode == 46)

    {

        if (obj.value.indexOf('.') >= 0)

        {

            alert('Too many decimals. Only numbers or one decimal.');

            return false;

        }

        return true;

    } else

    {

        alert('Only numbers or one decimal');

        return false;

    }

}
<a href='http://z54.com'>Coding example - Input Validation to check for Decimals<a/><br/>
Example: <input onkeypress="return IsDecimal(event,this)" type="text">