1 page: Set the text box of the old password as an html control. It is convenient to call javascript Functions. a div is placed next to it to display the prompt.
<Th style = "width: 60px">
Old password: </th>
<Td colspan = "3">
<Input id = "TB_OldPass" type = "password" onblur = "CheckPass ()"/>
<Div id = "Pass_Txt" style = "z-index: 101; left: 468px; width: 100px; position: absolute; top: 48px;
Height: 17px; display: none ">
</Div>
When the text box of the old password loses focus, the verification event CheckPass () is triggered ();
This function is in another js file. Do not forget to reference it on this page.
<Script language = "javascript" type = "text/javascript" src = "js/CheckPass. js"> </script>
File ChekcPass. js Code
Function CheckPass ()
{
// First obtain the old password characters
Var keys = document. getElementById ("TB_OldPass"). value;
// Asynchronous Data Transmission
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
Xmlhttp. onreadystatechange = statechangeLoad;
// Call the ModifyPass. aspx file to execute the background code.
Xmlhttp. open ("GET", "ModifyPass. aspx? Pass = "+ encodeURI (keys), true );
Xmlhttp. send (null );
}
Function statechangeLoad ()
{
If (xmlhttp. readystate = 4)
{
If (xmlhttp. status = 200)
{
// The password verification result is displayed on the page.
Document. getElementById ("Pass_Txt"). innerHTML = xmlhttp. responseText;
Document. getElementById ("Pass_Txt"). style. display = "";
// Determine whether the new password can be entered Based on the displayed characters.
If (document. getElementById ("Pass_Txt"). innerHTML = "the old password is successfully verified ")
{
Document. getElementById ("TB_NewPass"). readOnly = false;
Document. getElementById ("TB_NewRePass"). readOnly = false;
}
Else
{
// Directly focus on the text box of the old password, which is more user-friendly
Document. form1.TB _ OldPass. focus ();
}
}
}
}
Password verification events mainly rely on the Page_Lode event on the ModifyPass. aspx page
Protected void Page_Load (object sender, EventArgs e)
{
// Obtain the string of the passed Password
String Pass = Tools. GetMD5 (Request. QueryString ["Pass"]. ToString ());
// Obtain the ID of the current user
// String CurrentUserId = Session ["CurrentUserId"]. ToString ();
String CurrentUserId = "4 ";
// Determine whether the passed user ID and Password Match
DataSet ds = new DataSet ();
If (Business. Patient. CheckPass (Convert. ToInt32 (CurrentUserId), Pass ))
{
Response. Write ("the old password is successfully verified ");
}
Else
{
Response. Write ("failed to verify the old password ");
}
}
The password verification result is returned on this page, which is displayed on the homepage.