How to check if a text box is not empty and the value is less than 500

I have a textbox that is an optional field for users to enter a number in to. If there is a number in there, I want to check to make sure it is less than 500 and then do something with it.

Here is what I am currently doing:

if($textbox!="" && <=500)
{
//action here
}

I tried replacing && with andif but still get an error Parse error: syntax error, unexpected T_IS_SMALLER_OR_EQUAL

What's the easiest way to do this?


你需要在这两个语句中使用变量preg_match('/ d /',$ textbox)== 1将确保它是一个int

if($textbox!="" && $textbox <= 500 && preg_match('/d/', $textbox ) == 1)
{
//action here
}

你错过了小于左边的部分

if($textbox!="" && $textbox <=500)
{
//action here
}
链接地址: http://www.djcxy.com/p/12036.html

上一篇: 语法错误,意外的T

下一篇: 如何检查文本框是否为空并且值小于500