Reputation: 347
there is a Gridview
with textbox
and button
in each row. I am getting the value of textbox
and another column. After that I am creating SHA512
of both values then again it's need to update to the same password
textbox on button clicked for that corresponding row. How should I do this?
Below is the JQuery
event I am using:
<script type="text/javascript">
$(function () {
$("[id*=grduserdetail]").find("[id*=btnpass]").click(function () {
debugger;
//Reference the GridView Row.
var row = $(this).closest("tr");
var unm = row.find('.userid').text();
var pwd = row.find($('[id*=txtpass]')).val();
var pwdLength = false;
if (pwd.length >= 6)
pwdLength = true;
var hasUpperCase = /[A-Z]/.test(pwd);
var hasLowerCase = /[a-z]/.test(pwd);
var hasNumbers = /\d/.test(pwd);
var hasNonalphas = /[@#&!$%^&*()]/.test(pwd);
if (!((hasUpperCase + hasLowerCase + hasNumbers + hasNonalphas + pwdLength) > 4)) {
alert('Password must be 6 charaters long and contain one Upper case one lower case one digit and one special character !');
return false;
} else {
//$(this).prev()[0].value = SHA512(unm.text() + pwd.val());
pwd.value = SHA512(unm + pwd);
//document.getElementById("shhidden").value = SHA512(unm + pwd);
return true;
}
});
});
</script>
Upvotes: 0
Views: 246
Reputation: 1467
I believe SHA512(unm + pwd)
would be giving you the encrypted value as you need . to set password textbox's text as encrypted value (based on your comment) try:
var encryptedVal = SHA512(unm + pwd)
row.find($('[id*=txtpass]')).val(encryptedVal)
Upvotes: 1