I learned how to output content in the page before, and then we need to check whether the mailbox is correct. If this function is put into a function definition, it needs to return a result, and the returned result is an object, then we have to learn the object of js . Objects in js are defined as follows:
Everything in JavaScript is an object: strings, numbers, arrays, functions...
Also, JavaScript allows for custom objects.
JavaScript Objects
JavaScript provides several built-in objects, such as String, Date, Array, and so on.
Objects are just special data types with properties and methods.
Accessing properties of an object
Properties are values associated with an object.
The syntax for accessing object properties is:
objectName.propertyName
This example uses the length property of the String object to get the length of the string:
var message="Hello World!";
var x=message.length;
There are many ways to create objects, often There are two ways to use it. The first one is to create a JSON object. This is the JSON object of the name Dingding. It is a very simple relational data structure, but it is actually a tree structure. Its syntax is to use a curly bracket, like:
var bd = {
bind : function(input_element, tip_element, validate_func, null_tip, invalid_tip) {
var result = new Object();
result.valid = false;
//$("form#register #email") find span
$(tip_element).html(null_tip);
}
}
Here only one attribute bind is defined, and it is a function object. Created using curly braces, you can call it like this:
bd. bind ($("form#register #email"),
$("form#register #email").next(),
function(val) {return val.match("/^([.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{ 2,3}){1,2})$/");},
"<Please enter the email address",
"<The email address format is incorrect"
);
Another way to create an object is as follows:
var result = new Object() ;
result.valid = false;
To create an Object object here, the disadvantages of the above two methods of creating objects: it cannot be used as a template for object creation, that is, new objects cannot be constructed with new.
TensorFlow API strategyhttp :
Everything in JavaScript is an object: strings, numbers, arrays, functions...
Also, JavaScript allows for custom objects.
JavaScript Objects
JavaScript provides several built-in objects, such as String, Date, Array, and so on.
Objects are just special data types with properties and methods.
Accessing properties of an object
Properties are values associated with an object.
The syntax for accessing object properties is:
objectName.propertyName
This example uses the length property of the String object to get the length of the string:
var message="Hello World!";
var x=message.length;
There are many ways to create objects, often There are two ways to use it. The first one is to create a JSON object. This is the JSON object of the name Dingding. It is a very simple relational data structure, but it is actually a tree structure. Its syntax is to use a curly bracket, like:
var bd = {
bind : function(input_element, tip_element, validate_func, null_tip, invalid_tip) {
var result = new Object();
result.valid = false;
//$("form#register #email") find span
$(tip_element).html(null_tip);
}
}
Here only one attribute bind is defined, and it is a function object. Created using curly braces, you can call it like this:
bd. bind ($("form#register #email"),
$("form#register #email").next(),
function(val) {return val.match("/^([.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{ 2,3}){1,2})$/");},
"<Please enter the email address",
"<The email address format is incorrect"
);
Another way to create an object is as follows:
var result = new Object() ;
result.valid = false;
To create an Object object here, the disadvantages of the above two methods of creating objects: it cannot be used as a template for object creation, that is, new objects cannot be constructed with new.
Combining the above two methods, the test code can be written as follows:
<html> <head> <meta charset="utf-8"> <title> Examples of page prompts </title> <script type="text/JavaScript" src="jquery/jquery-3.3.1.js"></script> <script type="text/JavaScript"> $(document).ready(function(){ var bd = { bind : function(input_element, tip_element, validate_func, null_tip, invalid_tip) { var result = new Object(); result.valid = false; //$("form#register #email")找到span $(tip_element).html(null_tip); } } //Test the object to run bd.bind($("form#register #email"), $("form#register #email").next(), function(val) {return val.match("/^([.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/");}, "<Please enter your email address", "<The email format is incorrect" ); }); </script> </head> <body> <form id="register" action="" method="POST"> <table> <tbody> <tr> <td><label for="email">邮箱</label></td> <td><input type="text" id="email" name="email" /><span class="validate_tip"></span></td> </tr> <tr><td><input type="submit" id="register_btn" value="注册" /></td></tr> </tbody> </table> </form> </body> </html>
The results are as follows: