I took inspiration from a code of a login page from a certain website. I find a function which I do not know how to implement.
That login page uses two input controls in a form to gather username and password:
<form method="post" runat="server" action="myLogin.aspx">
<input type="text" class="us_name" name="txtUserName" id="txtUserName" value="" />
<input type="password" class="us_pwd" name="txtPassword" id="txtPassword" value="" />
</form>
and in that page, I also find some JQuery code like this:
<script language="javascript" type="text/javascript">
$(document).ready(function () {
var error = 0;
if (error > 0) {
switch (error) {
case 1:
$("#ListMsg").html("username and pwd can not be empty");
$("#txtUserName").focus();
break;
case 2:
$("#ListMsg").html("Pic code can not be empty");
$("#txtCheckCode").focus();
break;
case 3:
$("#ListMsg").html("Pic code err");
$("#txtCheckCode").focus();
break;
case 36006:
$("#ListMsg").html("username err");
$("#txtCheckCode").focus();
break;
case 36007:
$("#ListMsg").html("password err");
$("#txtCheckCode").focus();
break;
case 20012:
$("#ListMsg").html("account is lock");
$("#txtCheckCode").focus();
break;
case 10007:
$("#ListMsg").html("can not access");
$("#txtCheckCode").focus();
break;
default:
$("#ListMsg").html("username or password err");
$("#txtPassword").focus();
break;
}
}
});
It seems that above code is to display error message when login fails, but please notice this statement:
var error = 0;
When I type a wrong password and view page source, I find it has automatically changed to :
var error = 36007;
I guess this variable must be changed by server side code when login fails and use it to indicate fail reason. But I do not know how server can set client side JQuery variable's value, can anybody give me an example?