Do you know how to set JS object dynamic Truth?
Do you know the difference between json.stringfy () and Json.parse ()?
Do you know the difference between quoted and unquoted parameters?
Do you know the use of eval? www.javait.org
Look at the code below.
$ (function () {
$ (' #bankCardNo2 '). Bind ("Blur", function () {
Validatecardno (' Bankcardno ', ' BankCardNo2 ', ' Bankcardno ');//Here The parameter is passed with the quotation mark, the indicator is a value, the $ ("#" + variable value) can be used directly.
});
});
Function Validatecardno (cardnoel,cardnovalidateel,attrname) {
var cardno1=$ ("#" +cardnoel). Val ();
var cardno2=$ ("#" +cardnovalidateel). Val ();
//console.log ("CardNo2:" +cardno2);
if (cardno2!=cardno1) {
$ ("#" +cardnoel). Tips ({
Side:3,
msg: ' two times the card number entered is inconsistent! ',
bg: ' #AE81FF ',
Time:3
});
$ ("#" +cardnoel). focus ();
return false;
}else{
Var argdata=new object ();//Create objects There are many ways to create objects oh. You can use this method to have the dynamic property
argdata[attrname]=cardno1;//property name is Attrname value
Console.log ("Json.stringify (argdata):" + Json.stringify (Argdata));//json.stringfy () is converting the object to Json,json.parse () is converting the variable to JSON.
$.post ("Bizcustomer/getlistbyattr.do", Eval ("(" +json.stringify (argdata) + "), function (data) {//eval, which need to be executed immediately, To pass information to the background processing
if (data && data!= ") {
$ ("#" +cardnoel). Tips ({
Side:3,
Msg: ' Card number: ' +idnumber+ ' already exists,
BG: ' #AE81FF ',
Time:3
});
$ ("#" +cardnoel). focus ();
return false;
}else{
var reg =/(^\d{15}$)/;
if (reg.test (cardNo1) = = = False)
{
$ ("#" +cardnoel). Tips ({
Side:3,
Msg: ' Card number input is not legal ',
BG: ' #AE81FF ',
Time:3
});
}
$ ("#" +cardnoel). focus ();
return false;
}
});
}
}
A way to get to know the details in JS