This example shows how to use a modal window for changing user password. The new password is verified and updated without page refresh.
userss.Reg.Visible = not userss.EditMode userss.Edit.Visible = userss.EditMode
If (not userss.EditMode) Then
If (userss.user_password.Value <> userss.cuser_password.Value) Then
userss.Errors.addError("Password and confirmation password doesn't match")
End If
If (Len(userss.user_password.Value) < 5) Then
userss.Errors.addError("Password length must be more than 5 symbols")
End If
End If
The code is used to check that the password and confirmation password values
are identical. Password values should be at least five characters in length
for a minimum level of security
If (changePass.cpass.Value <> changePass.npass.Value) Then
changePass.Errors.addError("Password and confirmation password doesn't match")
End If
dim c
c = CCDLookUp("COUNT(*)","users","user_id="&DBInternetDB.ToSQL(changePass.uid.Value,ccsInteger)&" AND user_password="&DBInternetDB.ToSQL(changePass.opass.Value,ccsText),DBInternetDB)
If (c < 1) Then
changePass.Errors.addError("Current password and entered password doesn't match")
End If
If (Len(changePass.npass.Value) < 5) Then
changePass.Errors.AddError "Password length must be more than 5 symbols"
End If
The code checks that the value of the existing password precisely matches
the one specified in the Old Password field and the Confirmation Password
matches the New Password value. The new password value should be at least
five characters in length for a minimum level of security.
document.getElementById('Panel2changePassuid').value = document.getElementById('Panel1userssuser_id').value; if (document.getElementById("errors") == null)
{
Panel2ShowModal1_hide();
}
else
{
Panel2ShowModal1_show();
}
$("Panel2changePassCancel").onclick = function()
{
Panel2UpdatePanel1_refresh();
Panel2ShowModal1_hide();
return false;
}
16. Add the javascript code to the "userss" Record’s client-side OnLoad event:
if ($("Panel1userssEditchangePass") != null)
$("Panel1userssEditchangePass").onclick = function()
{
Panel2ShowModal1_show();
return false;
}
This code displays the Modal Window when the "changePass"
Link is clicked on the Record form.
$("Panel2").location = window.location.href;
document.getElementById("Panel2changePassuid").value =
document.getElementById("Panel1userssuser_id").value;
<font color="red"><span id="loginwarning"> </span></font>Red color of the warning message will help users quickly find out if a user with the specified login already exists.
method = "post";
parameters["login"] = document.getElementById("Panel1userssuser_login").value;
The code above sends the specified login value to the server using POST
method.
Dim c
Dim Conn
Set Conn = New clsDBInternetDB
Conn.Open
c = CCDLookUp("COUNT(*)","users","user_login="&Conn.ToSQL(CCGetFromPost("login", Empty),ccsText),Conn)
Response.Write(c)
and returns the result to the client in a string format.
if (transport.responseText == 0)
{
document.getElementById("loginwarning").innerHTML = "";
}
else
{
document.getElementById("loginwarning").innerHTML = "This login already taken";
}
So if a user with the specified login already exists in the database, "This
login already taken" message will appear in the user_login TextBox.
/*Page Style @modal-56276963*/
.ModalShowDiv {
position: absolute;
margin: 100px auto;
background-color: transparent;
border:0px solid #000;
padding:0px;
text-align:center;
z-index: 200;
display: none;
top: 100px;
left: 50%;
margin-left: -134px;
}
/*End Page Style*/
Database: Internet
Tables: users