I want to do a simple thing: I want to compare data from two input fields. I mean: the user will fill in the field with his password, and another field will appear asking you to enter his password again. I want to compare these two data to make sure they match. My problem is that I don’t know how to get the data from the confirmation field to compare it. The relevant part of the code is here (confirmaSenha is a confirmation field):
{name:'senha', width:80, sortable:true, editable: true, hidden:true, edittype:'password', editrules:{edithidden:true, required:true, custom:true, custom_func:validaSenha}},
{name:'confirmaSenha', width:80, sortable:true, editable: true, hidden:true, edittype:'password', editrules:{edithidden:true, required:true}},
function validaSenha(value, colname){
if (colname=='senha' && value == HOW_DO_I_GET_DATA_FROM_CONFIRMATION_FIELD?) {
return [true, ""];
}
else {
return [false, ""];
}
}
edited
if ((colname == 'senha') && (value == $('#tr_confirmaSenha').val())) {
alert('true');
return [true, ""];
}
else {
var senha = $("#tr_confirmaSenha").val();
alert(senha);
$("td.editmsg", 'FrmGrid_grid').html("Senhas diferentes.");
return [false, ""];
}
}
Thanks in advance.
source
share