Want only one or|two digits number before the decimal point in textfield flutter. And User can't add more than three digits after the decimal point

Issue

Only one or two digits number before the decimal point in texfFormField flutter. And User can’t add more than three digits after the decimal point.

Solution

you can use RegExp class

final isValidNumber = RegExp(r'^([0-9]{2})*\.[0-9]{2}$');

if (!isValidNumber .hasMatch(number))
    numbererror = "Please Enter Valid Name";
else
   numbererror = "";

Answered By – bhagavati antala

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *