0

Can any body help how to validate the price field in jquery and php the sample currency is

 120
120.25
12,23,000
1,000.89

I am using this expression but it does not accept comma(,)

it is in jquery

value.match(/^[+]?\d+(?:\.\d{1,3})?$/);

and in php i am using 
return (bool) preg_match('/^[0-9]+(\.[0-9]{0,2})?$/', $str);
4

1 回答 1

1

filter_var($int, FILTER_VALIDATE_INT) 用于整数和 filter_var($float, FILTER_VALIDATE_FLOAT) 用于浮点过滤器变量过滤并验证您的输入 (http://php.net/manual/en/function.filter-var.php)。

于 2012-12-27T06:47:40.553 回答