UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Formatting TextField while the user is typing

Forums > SwiftUI

Hello,

I'm a rather new to coding with Swift UI. I have been stuck on trying to format the text in a textfield while the user is typing. What I mean is that while the user write something it always comforms to a pre-defined format, such as "dd/mm/yyyy". Is there anyway to do achieve this? I would be thankful for any help.

2      

Hi bentheten2002 Not sure what you want to do with the text from textfield. If it a Date then you are better using a DatePicker to return the date which will format to users setting on dates.

Selecting dates and times with DatePicker

If you want a format eg email address or password must have certain letters etc then you can do a check that it correct before allowing user to go past this point.

Checking for a valid address

2      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.