js??? > < /script >
< /body >
< /html >
407
Chapter 14: More Interactive Content with JavaScript
Figure 14-3
The form at the moment has nothing special. If the Submit button is pressed, it is submitted to the server
as usual whether it is valid or not. It is needed to provide a way to interpret and to apply the rules of the
validation attributes. The last line before the closing of the body element includes a JavaScript file that is
where the validation logic is executed. Note that the content layer and the behavior layer do not make
any assumption on the used rules; they both work only on the convention that a certain rule can exist
with a certain name and parameters. If in the form a new field is added with a validation attribute, there
is no need to change the behavior layer unless a rule that is not already defined is introduced.
The haXe code to compile the main.js file must contain the definition of the rules and a mechanism to
apply the rules to the controls. The FormValidator class is responsible for managing one form at the
time enhancing the controls it contains with the validation behaviors.
Pages:
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771