Home > Net >  How to prevent entering numbers in Flutter TextFormField?
How to prevent entering numbers in Flutter TextFormField?

Time:09-15

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

CodePudding user response:

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

CodePudding user response:

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

You need to add this

CodePudding user response:

Try this:

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