Emir Bolat
Emir Bolat

Reputation: 1049

How to prevent entering numbers in Flutter TextFormField?

I am developing an application with Flutter. I put TextFormField. I want to prevent entering numbers in this TextFormField. How can I do that?

Upvotes: 0

Views: 611

Answers (3)

Sergio Clemente
Sergio Clemente

Reputation: 888

Try this:

TextFormField(
 inputFormatters: <TextInputFormatter>[
      FilteringTextInputFormatter.deny(RegExp('[0-9]')),
  ], 
),

Upvotes: 5

Balaji
Balaji

Reputation: 2077

   inputFormatters: [
                      FilteringTextInputFormatter.deny(RegExp("[0-9]")),
                    ],

You need to add this

Upvotes: 1

BLKKKBVSIK
BLKKKBVSIK

Reputation: 3548

You can use the validator argument to create a callback if the user input a number. You can also add the keyboardType argument to limit the user to only text with the value TextInputType.text

Upvotes: 3

Related Questions