kingberrill of Javascript
6/30/2016 - 10:42 AM

checking for Floating point numbers

checking for Floating point numbers

//  Examples of some floating numbers
// 7.2935
// -12.72
// 1/2
// 12.4e3 [ Equivalent to 12.4 x 103 ]
// 4E-3 [ Equivalent to 4 x 10-3 ]

    var decimal=  /^[-+]?[0-9]+\.[0-9]+$/;
    if(value.match(decimal))
    {
        alert('True') // has decminal or is a floating number;
    }
    else
    {
        alert('false') // no decimal or is not a floating number

    }