TextField phone number checker and email address

Hi,

Is there anyway to auto format a text field to show mobiles numbers properly like a modifier or something ? and is there an API to check if the text is a valid mail address not just dummy text ?

-- Kind Regards

Answered by DTS Engineer in 803992022

[@Ammar S. Mitoori](https://developer.apple.com/forums/profile/Ammar S. Mitoori) There is a specific keypad for entering telephone numbers which would display only telephone number options. .keyboardType(.phonePad)

Alternatively you could also use the TextField(_:value:formatter:prompt:) API and create a Formatter to convert to and from your specific representation.

Accepted Answer

[@Ammar S. Mitoori](https://developer.apple.com/forums/profile/Ammar S. Mitoori) There is a specific keypad for entering telephone numbers which would display only telephone number options. .keyboardType(.phonePad)

Alternatively you could also use the TextField(_:value:formatter:prompt:) API and create a Formatter to convert to and from your specific representation.

For the email address, there isn't an API to check the validity of an email, however you could use NSPredicate to validate the structure of the text if it matches that of a valid email address.

TextField phone number checker and email address
 
 
Q