//eval is to calculate the string [you can put any js The value in the code is
//1,
var str1='12 3';
eval(str1);//15
//2、
var str2='[1,2,3]';
eval(str2[0]);//1
//3.
eval('alert("abc")');//Pop up abc
//4.
var str="function show(){alert('love you');}";
eval(str);
show();
//5. eval--->json string
1. If the above user name and email verification input are blank, the traditional method is
Copy code
The code is as follows:
function FormField(fieldName, fieldDesc) {//Encapsulate the changer attribute fields and descriptions
this.fieldName = fieldName;
this.fieldDesc = fieldDesc;
}
String.prototype.MyTrim = function () {//Remove leading and trailing spaces
. >
var oUl = document.getElementById("ulError");
oUl.innerHTML = "";
var list = new Array
(
//You only need to verify that it is empty in the future Just add an object to the array
new FormField("name", "username"),
new FormField("email", "mail")
var flag = true; eval operation
if (fv == null ||!fv.MyTrim()) {
fieldDesc " Cannot be empty liError.innerHTML =list[i].fieldDesc " Cannot be empty";
🎜>