【www.gdgbn.com--js教程】

/*
js验证
<script type="text/javascript教程">
var dnum=document.getElementById("fenshu");
dnum.onkeyup = function(){
this.value=this.value.replace(/D/g,"");
if(dnum.value>1000||dnum.value<100){
         dnum.value=100;
}
}
</script>
*/

//php教程验证
$var=300;

$int_options = array(
"options"=>array
(
"min_range"=>0,
"max_range"=>256
)
);

if(!filter_var($var, FILTER_VALIDATE_INT, $int_options))
{
echo("Integer is not valid");
}
else
{
echo("Integer is valid");
}

//方法三js

var reg = /d{2,3}/;
var s = 888;
alert(reg.test(s));

//php正则

^([1-9][0-9][0-9]|1000)$

/*
这里我们主要是用到了正则表达式来完成,验证数字是否在指定的数据间距之间。
*/
?>

本文来源:http://www.gdgbn.com/wangyezhizuo/25086/