官术网_书友最值得收藏!

Designing the State of Our Application

A typical pattern in modern web applications is that when there is a form with multiple input fields, one input field might rely on another input field. For example, a password field may affect a password confirmation field by requiring that the two fields match with each other. While this validation is being performed, there is another validation happening which will prevent the user from clicking the submit button if there are errors. In addition, there will be other fields that will affect each other. For example, a password field may require the password to be different from the username entered. For the purpose of our example, we are going to build a form where someone can sign up for an account. They will need to enter:

  • A username
  • A password
  • A password confirmation
  • An email address

In terms of validations, we will want to make sure that:

  • The username is filled out.
  • The password is filled out.
  • The password matches the confirmation.
  • The email address is at least in the format of (someusername)@(somedomain.com).
  • The submit button is grayed out if there are any errors.

    Note

    We are intentionally using an overly simplistic method of validating email addresses here to avoid complexity.

主站蜘蛛池模板: 怀安县| 秦皇岛市| 乳山市| 凤阳县| 朔州市| 梨树县| 江川县| 玛多县| 新野县| 丰都县| 雅安市| 图木舒克市| 文水县| 福鼎市| 禄丰县| 双鸭山市| 泾川县| 新竹县| 曲靖市| 墨竹工卡县| 任丘市| 浦东新区| 曲松县| 柞水县| 平山县| 根河市| 丰台区| 改则县| 神农架林区| 永登县| 肥城市| 普洱| 新竹县| 托克逊县| 黄陵县| 陕西省| 舞钢市| 自贡市| 汽车| 滨州市| 米林县|