From 39e29bbaaf72bd230ef7882c5bb8db9d30440543 Mon Sep 17 00:00:00 2001 From: Sourabh Bhardwaj Date: Tue, 15 Feb 2022 12:26:32 +0530 Subject: [PATCH] Removing space from email field --- .../Atoms/FormFields/TextFields/TextEntryField.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 7973d652..dfe1256a 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -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