Files
crm.e5.pl/modules/EcmWorkCosts/js/editView.js
2024-04-27 09:23:34 +02:00

62 lines
1.6 KiB
JavaScript

$(document).ready(function () {
var tmp = $("#pesel");
tmp.blur(function () {
if (tmp.val().length != 0) {
if (!validatepesel(tmp.val(),$("birthday").val())) {
alert("Nie prawidłowy numer pesel!");
// document.getElementById("pesel").focus();
}
}
});
tmp = $("#bank_account_number");
tmp.blur(function () {
if (tmp.val().length != 0) {
if (!NRBvalidatior(tmp.val())) {
alert("Nie prawidłowy numer konta!");
// document.getElementById("bank_account_number").focus();
}
}
});
tmp = $("#email1");
tmp.blur(function () {
if (tmp.val().length != 0) {
if (!validateEmail(tmp.val())) {
alert("Nie prawidłowy adres email!");
//document.getElementById("email1").focus();
}
}
});
});
function validatepesel(pesel, birthday) {
var reg = /^[0-9]{11}$/;
if (reg.test(pesel) == false) {
//return false;
}
return true;
}
function NRBvalidatior(nrb) {
nrb = nrb.replace(/[^0-9]+/g, '');
var Wagi = new Array(1, 10, 3, 30, 9, 90, 27, 76, 81, 34, 49, 5, 50, 15, 53, 45, 62, 38, 89, 17, 73, 51, 25, 56, 75, 71, 31, 19, 93, 57);
if (nrb.length == 26) {
nrb = nrb + "2521";
nrb = nrb.substr(2) + nrb.substr(0, 2);
var Z = 0;
for (var i = 0; i < 30; i++) {
Z += nrb[29 - i] * Wagi[i];
}
if (Z % 97 == 1) {
return true;
} else {
return false;
}
} else {
return false;
}
}
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}