After the password is successfully modified, the logon page is displayed three seconds after the countdown.

Source: Internet
Author: User

Simple Description: on demand, after the password is changed, there will be a countdown of 3 seconds. After the countdown is completed, the logon page will be returned, instead of changing the password. The logon page will be returned immediately.

Code:

// Html code <Div class = "Portlet light bordered" id = "loginbox">
<Div class = "tab-content">
<Div class = "row">
<Form action = "" class = "horizontal-form" method = "Post" id = "searchform" AutoComplete = "off">
<Div class = "col-md-12">
<Div class = "col-md-6">
<Label class = "control-label Flex" style = "margin-top: 10px;">
Original password:
</Label>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Div class = "control-group">
<Div class = "controls">
<Div class = "main_input_box">
<Input type = "password" name = "name" id = "passwordori" class = "form-control"
Placeholder = "Enter the original password"
Maxlength = "50" allowkeyboard = "true" value = ""/>
</Div>
</Div>
</Div>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Label class = "control-label Flex" style = "margin-top: 10px;">
New password:
</Label>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Div class = "control-group">
<Div class = "controls">
<Div class = "main_input_box">
<Input type = "password" name = "name" id = "passwordnew" class = "form-control"
Placeholder = "enter a new password"
Maxlength = "50" allowkeyboard = "true" value = ""/>
</Div>
</Div>
</Div>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Label class = "control-label Flex" style = "margin-top: 10px;">
Confirm new password:
</Label>
</Div>
</Div>
<Div class = "col-md-12">
<Div class = "col-md-6">
<Div class = "control-group">
<Div class = "controls">
<Div class = "main_input_box">
<Input type = "password" name = "name" id = "passwordcon" class = "form-control"
Placeholder = "confirm new password"
Maxlength = "50" allowkeyboard = "true" value = ""/>
</Div>
</Div>
</Div>
</Div>
</Div>
</Form>
<Div class = "col-md-6" style = "margin-top: 10px; float: Right; clear: Right" id = "showmsg">
<Button class = "BTN sbold default" id = "resetconten" style = "float: Right; margin-left: 10px;">
<SPAN class = "Ladda-label"> clear </span>
</Button>
<Button class = "BTN sbold blue" id = "Confirm" style = "float: right;">
<SPAN class = "Ladda-label" onclick = "checkserver ()"> confirm modification </span>
</Button>
</Div>
</Div>
</Div>
</Div>
// JS Code $. Ajax ({
Type: "Post ",
URL: rootpath + '/PRI/user/changepassword ',
Data: {keydata: Code },
Datatype: 'json ',
Cache: false,
Success: function (data ){
If ("success" = data. Result ){
$ ("# Loginbox"). Tips ({
SIDS: 1,
MSG: "The modification is successful. The logon page will be returned in 3 seconds. Please log on again! ",
BG: '# ff5080 ',
Time: 3
});
VaR T = parseint (3 );
Window. setinterval (function (){
If (T> 0 ){
$ ("# Showmsg" cmd.html ('remaining <a class = "flip-link BTN-Info">' + T + 'second' + '</a> second refresh ');
} Else {
VaR Path = rootpath + 'main/logout ';
Top. Location. href = path;
}
T --;
},1000 );
} Else if ("fail" = data. Result ){
$ ("# Passwordori"). Tips ({
Side: 1,
MSG: "Incorrect original password input ",
BG: '# ff5080 ',
Time: 3
});
$ ("# Passwordori"). Focus ();
Return false;
} Else {
$ ("# Passwordori"). Tips ({
Side: 1,
MSG: "exception ",
BG: '# ff5080 ',
Time: 3
});
$ ("# Passwordori"). Focus ();
Return false;
}
}
});

Conclusion: The Code mainly uses window. setinterval (code, delayFor more information, see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/setInterval

After the password is successfully modified, the logon page is displayed three seconds after the countdown.

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.