Use js to determine whether the TextBox control value is changed and then start the event

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Script language = "javascript" type = "text/javascript">

Var firsty; // The year and month when the page is loaded at the beginning
Var firstm;

Var secondy; // value after onchange is triggered
Var secondm;
Var panduan = 0; // determines whether the change has occurred

Function onloadload () // assign the initial value to the global variable. Call <body onload = "onloadload ()">
{
Firsty = document. getElementById ("txtYear"). value; // The year and month when the page is first loaded.
Firstm = document. getElementById ("txtMonth"). value;

Secondy = document. getElementById ("txtYear"). value; // value after onchange is triggered
Secondm = document. getElementById ("txtMonth"). value;
}

 

Function changeym () // triggered when the focus is lost. Determine whether the onfocusout = "changeym ();"
{
Secondy = document. getElementById ("txtYear"). value;
Secondm = document. getElementById ("txtMonth"). value;
If (parseInt (secondy, 10 )! = ParseInt (firsty, 10) | parseInt (secondm, 10 )! = ParseInt (firstm, 10) // The conversion takes into account the difference between month 3 and 03.
{
Panduan = 1; // change
Alert ('Re-retrieve data! ');
Document. getElementById ("btnCurPayLoad"). click ();
}
Else
{
Firsty = secondy; // assign values so that changes are made after changes
Firstm = secondm;
}
}

</Script>

Related Article

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.