踏浪飞鸿的专栏

宁静而致远,淡薄以清心...

转载 javascript检查数值类型函数收藏

<script>
//检查是否为任意数(实数)
function isNumeric(strNumber) {
var newPar=/^(-|\+)?\d+(\.\d+)?$/
alert(newPar.test(strNumber)); }
//检查是否为正数
function isUnsignedNumeric(strNumber) {
var newPar=/^\d+(\.\d+)?$/
alert(newPar.test(strNumber)); }
//检查是否为整数
function isInteger(strInteger) {
var newPar=/^(-|\+)?\d+$/
alert(newPar.test(strInteger)); }
//检查是否为正整数
function isUnsignedInteger(strInteger) {
var newPar=/^\d+$/
alert(newPar.test(strInteger)); }
</script> 

发表于 @ 2006年10月17日 16:40:00|评论(loading...)

新一篇: 存储过程介绍及asp+存储过程的使用 | 旧一篇: JavaScript 实用的一些技巧

Csdn Blog version 3.1a
Copyright © 踏浪飞鸿