Removing space from email field

This commit is contained in:
Sourabh Bhardwaj 2022-02-15 12:26:32 +05:30
parent 1f9980aa9b
commit 39e29bbaaf

View File

@ -50,6 +50,7 @@ import UIKit
//--------------------------------------------------
private var observingForChange: Bool = false
private let emailTag = 3
/// Validate when user resigns editing. Default: true
public var validateWhenDoneEditing: Bool = true
@ -229,7 +230,12 @@ import UIKit
/// Validates the text of the entry field.
@objc public override func validateText() {
text = textField.text
var value = textField.text
if (textField.tag == emailTag) {
// remove spaces (either user entered Or auto-correct suggestion) for the email field
value = value?.replacingOccurrences(of: " ", with: "")
}
text = value
super.validateText()
}
@ -347,6 +353,7 @@ import UIKit
case .email:
textField.keyboardType = .emailAddress
textField.tag = emailTag
case .phone:
textField.keyboardType = .phonePad