O'Reilly logo

Learning Dart - Second Edition by Ivo Balbaert

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spiral 2 – how to validate data with Dart

If you have tested the Spiral 1 – the power of HTML5 forms version thoroughly, you would have come across some things that could be improved:

  1. The HTML5 control only does its checks when the Create Account button is clicked; it would be better if the user is alerted earlier, preferably after filling in each field.
  2. The Birth Date value is checked to be a correct DateTime value, but a value in the future is accepted.
  3. The Gender field will gladly accept other values than M or F.
  4. The Balance field accepts a negative number.

So, HTML5 doesn't give us full validation possibilities. To remedy and supplement this, we must add code validation, see bank_terminal_s2.dart:

Note

For the code files of this section, refer to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required