diff --git a/OmiseSDK/Sources/Views/Components/TextFields/CardCVVTextField.swift b/OmiseSDK/Sources/Views/Components/TextFields/CardCVVTextField.swift index 9a58ff1c..fb99b340 100644 --- a/OmiseSDK/Sources/Views/Components/TextFields/CardCVVTextField.swift +++ b/OmiseSDK/Sources/Views/Components/TextFields/CardCVVTextField.swift @@ -6,6 +6,8 @@ import UIKit open class CardCVVTextField: OmiseTextField { private let validLengths = 3...4 + open var shouldBeginEditingHandler: (() -> Bool)? + open override var delegate: UITextFieldDelegate? { get { return self @@ -62,4 +64,9 @@ extension CardCVVTextField { return maxLength >= (self.text?.count ?? 0) - range.length + string.count } + + open func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool + { + return shouldBeginEditingHandler?() ?? true + } } diff --git a/OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift b/OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift index 43a717d1..21a30f6d 100644 --- a/OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift +++ b/OmiseSDK/Sources/Views/Components/TextFields/CardNumberTextField.swift @@ -15,6 +15,8 @@ open class CardNumberTextField: OmiseTextField { return pan.brand } + open var shouldBeginEditingHandler: (() -> Bool)? + open override var tokenizer: UITextInputTokenizer { return cardNumberStringTokenizer } @@ -310,4 +312,9 @@ extension CardNumberTextField { return maxLength >= (self.text?.count ?? 0) - range.length + string.count } + + open func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool + { + return shouldBeginEditingHandler?() ?? true + } }