[JavaScript] 表单验证不通过不提交的JS写法


主要是本世纪初的写法.

Example 2: event handler Javascript

(Yep, early 21st century Javascript was pretty lame, too).

 

One unifying characteristic that these early Javascript experiments had was that the Javascript was tightly intertwined with the HTML. Buttons had onclickonmouseoveronmouseout, etc. handlers whose code was either in the  section of the HTML page if you were lucky, or included just before the code that used it if you were less lucky. What ended up happening as a result was that code ended up being cut and pasted and slightly modified into different contexts. As Javascript got to be more and more complex, the desire for reusable components was greater, and Javascript implementations started supporting more of what was called "unobtrusive" Javascript. An unobtrusive form handler would have been implemented as:


Example 3: Unobtrusive Javascript form validation
====================

 

你可能感兴趣的:([JavaScript] 表单验证不通过不提交的JS写法)