function vmIsPhone(evt) { return evt.match(/[0-9]+/g); } /* walidacja zgodnosci 2 pol */ function vmFormValidation_2Field(field1,field2,noteAlert) { var fieldName1 ="content_register_"+field1; var fieldName2 ="content_register_"+field2; if (document.getElementById(fieldName1).value!=document.getElementById(fieldName2).value) { if (document.getElementById(fieldName1).value!="" && document.getElementById(fieldName2).value!="") { alert("Podane adresy e-mail sa rozne!"); document.getElementById(fieldName1).value =""; document.getElementById(fieldName2).value =""; } } return true; } /* waldiacja kodu pocztowego */ var _kod_wzorzec = /^[0-9]{2}-[0-9]{3}$/; function vmFormValidation_ZipCode(field) { var errorCommun =""; var errorStatus ="1"; var KOD =document.getElementById(field).value; if (KOD == null || KOD == "") { errorStatus = "0"; errorCommun = "Brak kodu"; } else if (_kod_wzorzec.test(KOD)) { errorStatus = "1"; errorCommun = ""; } else { errorStatus = "0"; errorCommun = "Kod niepoprawny"; }; if (errorStatus=="0") { alert(errorCommun); document.getElementById(field).value=""; } return false; }; /* waldiacja NIP */ function vmFormValidation_ZIP(field) { var errorCommun =""; var errorStatus ="1"; var NIP =document.getElementById(field).value; if (NIP == null || NIP == "") { errorStatus = "0"; errorCommun = "Brak NIP"; } else if (NIP == "1234567890") { errorStatus = "0"; errorCommun = "NIP niepoprawny"; } // obsluga wyjatku else { NIP = NIP.replace(/[\s-]/g, ""); var CyfraKontrolna = parseInt(NIP.charAt(9)); var TablicaWag = [6, 5, 7, 2, 3, 4, 5, 6, 7]; if (NIP.length == 10 && parseInt(NIP, 10) > 0) { var SumaKontrolna = 0; for(var i = 0; i<9; i++) { SumaKontrolna += parseInt(NIP.charAt(i)) * TablicaWag[i]; } var WynikKontrolnyModulo = SumaKontrolna % 11; var ResztaKontrolna = (WynikKontrolnyModulo == 10)?0:WynikKontrolnyModulo; if (ResztaKontrolna == CyfraKontrolna) { errorStatus = "1"; errorCommun = "NIP poprawny"; } else { errorStatus = "0"; errorCommun = "NIP niepoprawny"; }; } else { errorStatus = "0"; errorCommun = "NIP niepoprawny"; }; }; if (errorStatus=="0") { alert(errorCommun); document.getElementById(field).value=""; } return false; };