swift3 - How to mandate a certain text phase in a textfield in swift -


how make sure email field has text ending @companyname.com wont proceed if ends @gmail.com?

@ibaction func login(_ sender: any) {     if self.emailfield.text != "" || self.passwordfield.text != "" && self.emailfield.text == //what put here?//     {     } } 

one option use hassuffix(:) check particular suffix.

@ibaction func login(_ sender: any) {     if self.emailfield.text != "" || self.passwordfield.text != "" && self.emailfield.text.hassuffix("@companyname.com")     {     } } 

Comments