TextField Validation With Regular Expression

后端 未结 4 1875
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 17:29

I need help with code that looks at a textfield make sure it starts with either a (+ or -) then has 3 integers after it.

So valid data looks like +234 or -888

4条回答
  •  伪装坚强ぢ
    2020-12-12 18:26

    Implement the -textField:shouldChangeCharactersInRange:replacementString in your UITextFieldDelegate and use NSRegularExpression to validate the changes.

提交回复
热议问题