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" >