【问题标题】:Codeigniter regex_match with moneyCodeigniter regex_match 与钱
【发布时间】:2013-01-18 20:11:43
【问题描述】:

我正在使用代码点火器 form_validation,我想知道是否有一个文本框可以验证资金,例如允许 4 个数字,然后是句点,然后是 2 个数字。

这是我目前得到的

regex_match[/^[0-9.]{0,7}+$/]

效果很好,但是我可以输入一个像 100.000 这样的数字,我能做些什么吗?

【问题讨论】:

标签: php forms codeigniter validation


【解决方案1】:

要完全按照您的要求进行匹配:

regex_match[/^\d{4}\.\d{2}$/] // allow 4 numbers only a period and then two numbers only

如果您想匹配最多 4 个数字,因此允许 1.00、10.00、100.00 但小数点前不超过 4 个数字,然后使用:

regex_match[/^\d{1,4}\.\d{2}$/]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 2023-02-16
    • 1970-01-01
    相关资源
    最近更新 更多