(vii) JavaScript [debug] and [Front-end form validation]

Source: Internet
Author: User

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]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.