Miscellaneous (datatable filtering, time formatting, JS verification number, JS summation)

Source: Internet
Author: User

 

(1) filter the data in the datatable:

Datatable dt = new datatable ();

Dataview DV = DT. defaultview;

DV. rowfilter = string. Format ("name = {0} And namet = {1}", value, valuet );

Datatable newdt = DV. totable ();

 

(2) query by time period Conditions

Data SQL statement: SJ between sj1 and sj2

When retrieving data in the background, format the string:

String sj1 = This. SJ. Text. Trim () = ""? "": Convert. todatetime (this. SJ. Text. Trim (). tostring ("D-M month-YYYY ");

 

(3) JS verification numbers

JS method:

Function valnum (ID ){

Var val = Document. getelementbyid (ID). value; // The value of each part.

VaR mod =/^ [+-]? /D + (/./d + )? $ // Verify the numerical Validity

If (Val! = ""){

If (! Mod. Test (VAL )){

Document. getelementbyid (ID + 'info'). style. Display = "Block ";

Return false;

} Else {

Document. getelementbyid (ID + 'info'). style. Display = "NONE ";

}

}

Else {

Document. getelementbyid (ID + 'info'). style. Display = "NONE ";

}

Return;

}

Add <span id = "bysrinfo" style = "color: red; display: none"> enter a number </span> behind the page label as a prompt Panel for information.

 

(4) JS summation

Directly process the obtained value with + =, and the program will be connected as a string ..

Function valtolnum (ID ){

Var val = Document. getelementbyid (ID). value; // The value of each part.

VaR valvalue = Document. getelementbyid ("bzhj"). value; // value of the total value control

VaR mod =/^ [+-]? /D + (/./d + )? $ // Verify the numerical Validity

If (Val! = "") {If (! Mod. Test (VAL) {...} // verify the information

// Calculate the obtained value * 1 as a number for the sum.

Valvalue = valvalue * 1 + val * 1;

Document. getelementbyid ("bzhj"). value = valvalue;

Return;

}

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.