The inheritance of Javascript classes implements code _javascript techniques

Source: Internet
Author: User
Tags inheritance
The learning of classes in JavaScript, inheriting from basic classes.
You can also implement this:
Java code
Copy Code code as follows:

function Newclass () {
This.firstname= "Frank";
This.touc=string.touppercase;
This.tostring=function () {
Return This.touc (This.firstname);
}
}
var nc=new newclass ();
Alert (NC);//no response in IE.
function Newclass () {
This.firstname= "Frank";
This.touc=string.touppercase;
This.tostring=function () {
Return This.touc (This.firstname);
}
}
var nc=new newclass ();
Alert (NC);//no response in IE.

A simple client-side validation
Java code
<ptml> <pead> <title>javascript</title> <script type= "Text/javascript" > function Dosubmit (Inform) {if (inform.firstname.value== ") {alert (" FirstName is null "); return false; } if (InForm.lastName.value = = "") {alert ("LastName is null"); } inform.submit (); return true; } </script> </pead> <body> <form action= "#" name= "test" method= "POST" > Name: <input Type= "text" name= "FirstName" > Last name:<input type= "text" name= "LastName" > <input type= "button" value = "Submit" onclick= "Dosubmit" (This.form); > </form> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

<ptml> <pead> <title>javascript</title> <script type= "Text/javascript" > function Dosubmit (Inform) {if (inform.firstname.value== ") {alert (" FirstName is null "); return false; } if (InForm.lastName.value = = "") {alert ("LastName is null"); } inform.submit (); return true; } </script> </pead> <body> <form action= "#" name= "test" method= "POST" > Name: <input Type= "text" name= "FirstName" > Last name:<input type= "text" name= "LastName" > <input type= "button" value = "Submit" onclick= "Dosubmit" (This.form); > </form> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

This is generally written
Java code
Copy Code code as follows:

<form action= "#" name= "test" method= "POST" onsubmit= "Return to Dosubmit (this);" >
Name: <input type= "text" name= "FirstName" >
<br>
Last name:<input type= "text" name= "LastName" >
<br>
<input type= "button" value= "Submit" >
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.