·建站首页 ·钻石 ·繁體
您的位置: 中国建站之家 -> 网站开发设计 -> ASP教程 -> Numeric Check with some Regular Expression magic

Numeric Check with some Regular Expression magic

作者:未知  来源:转载  发布时间:2005-7-20 11:44:17  发布人:acx

<script language="javascript" runat="server">
    // Checks that the string supplied can be expressed as a number (float)
    function isNumeric(strNumber) {
        return (strNumber.search(/^(-|\+)?\d+(\.\d+)?$/) != -1);
    }

    // Checks that the string supplied can be expressed as an unsigned number (float)
    function isUnsignedNumeric(strNumber) {
        return (strNumber.search(/^\d+(\.\d+)?$/) != -1);
    }

    // Checks that the string supplied can be expressed as an integer
    function isInteger(strInteger) {
        return (strInteger.search(/^(-|\+)?\d+$/) != -1);
    }

    // Checks that the string supplied can be expressed as an unsigned integer
    function isUnsignedInteger(strInteger) {
        return (strInteger.search(/^\d+$/) != -1);
    }
</script>

将本文收藏到QQ书签与更多好友分享

上一篇:好东西,老外用正则表达式写的HTML分离函数

下一篇:正则表达式简介(微软)--2.早期起源