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>