A way to get to know the details in JS

Source: Internet
Author: User

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

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.