jQuery Validate 中的奇怪数字验证
Strange number validation in jQueryValidate
我有一个这样的文本字段:
$("#someForm").validate({
rules: {
someNumber: {
number: true
}
}
});
正如预期的那样,4,12
或 3,1415
等输入的验证失败。
但是,它会验证以下输入 3,141
。
为什么?
number
规则正在寻找 "valid decimal number"。
As expected, validation fails for inputs like 4,12 or 3,1415.
However, it validates the following input 3,141. Why?
因为3,141
代表“三千一百四十一”.
逗号称为“千位分隔符”,在此位置有效...
In European languages, large numbers are read in groups of thousands and the delimiter (which occurs every three digits when it is used) may be called a "thousands separator"
https://en.wikipedia.org/wiki/Decimal_mark#Digit_grouping
要忽略逗号、句点、减号和数字以外的任何内容,请改用 the digits
method...
Makes the element require digits only
我有一个这样的文本字段:
$("#someForm").validate({
rules: {
someNumber: {
number: true
}
}
});
正如预期的那样,4,12
或 3,1415
等输入的验证失败。
但是,它会验证以下输入 3,141
。
为什么?
number
规则正在寻找 "valid decimal number"。
As expected, validation fails for inputs like 4,12 or 3,1415.
However, it validates the following input 3,141. Why?
因为3,141
代表“三千一百四十一”.
逗号称为“千位分隔符”,在此位置有效...
In European languages, large numbers are read in groups of thousands and the delimiter (which occurs every three digits when it is used) may be called a "thousands separator"
https://en.wikipedia.org/wiki/Decimal_mark#Digit_grouping
要忽略逗号、句点、减号和数字以外的任何内容,请改用 the digits
method...
Makes the element require digits only