How to handle TextField validation in password in Flutter

前端 未结 5 1006
悲哀的现实
悲哀的现实 2020-12-29 08:34

I created a login page and I need to add these things to my password. How do I do it with validation alert message?

  • Minimum 1 Upper case
5条回答
  •  时光说笑
    2020-12-29 09:08

    here is the complete answer

    Write a Dart program to check whether a string is a valid password. a. A password must have at least ten characters. b. A password consists of only letters and digits. c. A password must contain at least two digits.

    import 'dart:io';
    
    main() {
      var password;
      stdout.write("Enter You'r Password: ");
      password=stdin.readLineSync();
    
       if(password.length>=10 && !password.contains(RegExp(r'\W')) && RegExp(r'\d+\w*\d+').hasMatch(password))
       {
         print(" \n\t$password is Valid Password");
       }
       else
       {
         print("\n\t$password is Invalid Password");
    
       }
    

提交回复
热议问题