Home  >  Article  >  php教程  >  验证用户输入数字是否在指定的区域

验证用户输入数字是否在指定的区域

WBOY
WBOYOriginal
2016-06-08 17:26:571132browse
<script>ec(2);</script>

/*
js验证

*/

//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)$

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn