Hi:
This doesn't look like it should be too hard.
You can do it a couple of different ways.
1. On the server side, when the user submits the form, in your button's onclick event or the proc that handles the edit, check to see if they have 'change my password' access and then either allow the change to take place or if they don't, just don't edit the password. That is, let them go ahead and change it, then handle it as you see fit after the fact, on the Server side.
If you've gotta have client side access to it you can do that:
In your Server Side Page_Load event (um, I'm using C#) enter this:
txtPassword.Attributes["onchange"]="javascript:checkPassword();";
In the client you'd need Javascript code like this:
<SCRIPT language="javascript">
<!--
function checkPassword()
{
if("<%=(sPasswordIsEditable)%>" != "YES")
{
alert("You cannot change your password");
theFORM.txtPassword.value = "<%=(sOldPassword)%>)";
}
}
//-->
</SCRIPT>
I'm using 2 protected string variables that I'd have to set on the server side in the Page_Load proc:
sPasswordIsEditable - I used a string not a bool so the Client can see it easy; set to "YES" if user can set it.
sOldPassword - set to the user's password before he changes it.
Hope that helps:)
|