Home > Enterprise >  Disable Alphabetic characters in TextFormField
Disable Alphabetic characters in TextFormField

Time:11-20

in Flutter/Dart how can I disable all alphabetic characters while typing in a TextFormField ? I want only Numbers to be shown when the user type inside the field. Thank you. Example : when user type : Test2094 , the only shown text is 2094. but it's not only about showing text but the stored information should be only numbers.

CodePudding user response:

you should try with keyboard type number only and user can able to input digits only and import import 'package:flutter/services.dart';

          TextFormField(
                      keyboardType: TextInputType.numberWithOptions(
                        signed: false,
                        decimal: false,
                      ),
                      inputFormatters: <TextInputFormatter>[
                        FilteringTextInputFormatter.digitsOnly,
                      ],
                      
                      decoration: InputDecoration(
                        border: OutlineInputBorder(),
                        labelText: "Number*",
                      ),
                    )
  • Related