ColdFusion 9: int and type=“numeric” nasty bug?

前端 未结 2 1128
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-07 11:30

I\'ve just experienced a behaviour that defies any logic and could potentially lead to serious issues and was wondering if it was a bug or if the behaviour was itend

2条回答
  •  粉色の甜心
    2021-01-07 11:41

    You can use regular expressions to find out if there are any non numeric characters in a given form field:

    reFind( "[^\d-]", "1 2")
    

    That will match any character that is not a number, not a -

    If you want to check only positive numbers, you can use

    reFind( "[^\d]", "1 2")    
    

    If this returns true, you do not have an integer.

提交回复
热议问题