12 ", commissioning
Why do you want to debug?
1. When writing JavaScript, it would be painful to have no debugging tools.
2. It is difficult to write JavaScript programs without Debugging tools.
3. The code you write may contain syntax errors, logic errors, and if you do not use debugging tools, these errors are difficult to discover
4. Help locating the error message
In general, errors occur during the process of writing a new JavaScript code
Code debugging: Looking for errors in program code
Console.log ()
I use the Chrome Browser [console console, etc.] to debug because Chrome's developer tools are the best front-end Debugging tools
The debugger keyword is used to stop executing JavaScript and invoke the Debug function.
This keyword has the same effect as setting breakpoints in the Debug tool.
13 ", Form validation
1 <formAction="">2Mailbox:<inputID= "Email"type= "text"/>3 <inputID= "Submit"type= "button"value= "Submit" />4 </form>5 6 <Pstyle= "color:red;"ID= "Result"></P>
1 /**2 Verify Email3 not in line with actual development needs4 */5 6 function$ (ID) {7 returndocument.getElementById (ID);8 }9 Ten varemail = $ (' email '); One varresult = $ (' result '); A varSubmit = $ (' Submit '); - -Email.addeventlistener (' KeyUp ',function () { the if(Email.value.indexOf (' @ ') > 0) { -result.innerhtml = ' '; -}Else if(Email.value.indexOf (' @ ') < 0) { -result.innerhtml = ' Please enter the correct mailbox format, including @ '; + } -},false); + ASubmit.addeventlistener (' click ',function () { at if(Email.value = =NULL|| Email.value = = "'){ -result.innerhtml = ' mailbox must not be empty '; -}Else { - //judging length, not less than 6 bits - if(Email.value.length < 6){ -result.innerhtml = ' mailbox must not be less than 6 bits '; in } - } to},false);
(vii) JavaScript [debug] and [Front-end form validation]