I have a maskedTextbox with 2 events, onblur client side and OnTextChanged in server side.
My on blur method are returning true or false, if my return is true, i wanna enter in server side and do OnTextChanged, if return is false doesnt enter on server side and show a alert.
My problem is, my return can be true or false, doesnt make anything different, always enter in server side.
Thankz in advance!
My on blur method are returning true or false, if my return is true, i wanna enter in server side and do OnTextChanged, if return is false doesnt enter on server side and show a alert.
My problem is, my return can be true or false, doesnt make anything different, always enter in server side.
function
verificarCPF() {
var
contador;
var
valorCPF = $telerik.findMaskedTextBox(
"txtBuscaCpf"
).get_value();
var
numeroCPF = valorCPF.substr(0, 9);
var
digitoCPF = valorCPF.substr(9, 2);
var
d1 = 0;
for
(contador = 0; contador < 9; contador++) {
d1 += numeroCPF.charAt(contador) * (10 - contador);
}
if
(d1 == 0) {
radalert(
"CPF Inválido!"
,350,140,
"Mensagem"
,
null
,
null
);
return
false
;
}
d1 = 11 - (d1 % 11);
if
(d1 > 9) d1 = 0;
if
(digitoCPF.charAt(0) != d1) {
radalert(
"CPF Inválido!"
, 350, 140,
"Mensagem"
,
null
,
null
);
return
false
;
}
d1 *= 2;
for
(contador = 0; contador < 9; contador++) {
d1 += numeroCPF.charAt(contador) * (11 - contador);
}
d1 = 11 - (d1 % 11);
if
(d1 > 9) d1 = 0;
if
(digitoCPF.charAt(1) != d1) {
radalert(
"CPF Inválido!"
, 350, 140,
"Mensagem"
,
null
,
null
);
return
false
;
}
return
true
;
//radalert("CPF Válido!", 350, 140, "Mensagem", null, null);
}
<
telerik:RadMaskedTextBox
ID
=
"txtBuscaCpf"
ClientEvents-OnBlur
=
"verificarCPF"
AutoPostBack
=
"true"
runat
=
"server"
Mask
=
"###.###.###-##"
Width
=
"100"
OnTextChanged
=
"txtBuscaCpf_TextChanged"
/>
Thankz in advance!