Skip to content

Instantly share code, notes, and snippets.

@afarnham
Created January 23, 2023 02:20
Show Gist options
  • Save afarnham/86506f4c3f492191e360117f0b360d84 to your computer and use it in GitHub Desktop.
Save afarnham/86506f4c3f492191e360117f0b360d84 to your computer and use it in GitHub Desktop.
TextField("Target Weight", text: $viewModel.inputWeight)
                    .keyboardType(.decimalPad)
                    .onChange(of: viewModel.inputWeight, perform: { value in
                        viewModel.inputWeight = value.filter { "01234567890.".contains($0) }
                    })
                   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment