Numeric Check with some Regular Expression magic
发表于:2007-06-30来源:作者:点击数:
标签:
script language= java script 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
<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>
原文转自:http://www.ltesting.net