Verify that the user input number is in the specified range

Source: Internet
Author: User
Tags php tutorial regular expression valid

/*
JS Verification
<script type= "Text/javascript Tutorial" >
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 Tutorial Validation
$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");
}

Method Three JS

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

PHP Regular

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

/*
Here we use the regular expression to complete, verify that the number is between the specified data spacing.
*/
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.