// valid = wzorzec ciągu znaków
// where = form.inputObject
// error = wstawiany komunikat błędu w inputObject
function Validate(where, valid, error) {
	if (where.value!='') {
		test = where.value.match(valid);
		where.value = (test == null ? (error == null ? 'Błąd !!' : error) : test); }
	else {
		test=1; }
	if (test == null) {
		with (where.style) {
			color = 'yellow';
			background = 'red';
			fontWeight = 'bold'; } }
	else {
		with (where.style) {
			color = 'black';
			background = 'white';
			fontWeight = ''; } }
}

pesel = /^[0-9]{11}$/;
cell = /^[568][01689][0-9]{7}$/;
//cell = /^50|51|60|66|69|88{2}\d{9}$/;
zipCode = /^[0-9]{2}-[0-9]{3}$/;
nip = /^[0-9]{3}-[0-9]{3}-[0-9]{2}-[0-9]{2}$/;
email = /^[a-zA-Z0-9\_\-\.]+@[a-zA-Z0-9\_\-\.]+\.\w{2,}$/;
//email = /^.+@.+\..+{2,}$/;
date = /^[0-9]{4}-[0-1]{1}[0-9]{1}-[0-3]{1}[0-9]{1}$/;

function ValidatePESEL(where) {Validate(where, pesel);}
function ValidateCell(where) {Validate(where, cell);}
function ValidateZipCode(where) {Validate(where, zipCode);}
function ValidateNIP(where) {Validate(where, nip);}
function ValidateEMail(where) {Validate(where, email);}
function ValidateDate(where) {Validate(where, date);}

