function VerifyEmpty(str) { for (i = 0; i < str.length; i++) { if (!(str.charAt(i) == " " || str.charAt(i) == "\t")) { return false; } } return true; } function VerifyPhoneNumLength(phonenum) { if(phonenum.length>=7){ return true; } } function VerifyEmail(str) { if(!str.match(/^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,6}$/i)) { return false; } else { return true; } } function checkPay(form) { var isCorrect = true; var ErrorText = ""; if(VerifyEmpty(form.name.value)) { ErrorText += "\u00B7 Kérjük adja meg a nevét.\n"; isCorrect = false; } if( (VerifyEmpty(form.email.value)) && (VerifyEmpty(form.phone.value)) ) { ErrorText += "\u00B7 Kérjük adja meg a telefonszámát vagy e-mail címét.\n"; isCorrect = false; } if(!VerifyEmpty(form.email.value) && !VerifyEmail(form.email.value)) { ErrorText += "\u00B7 Az e-mail címet nem helyesen töltötte ki!\n"; isCorrect = false; } if(!VerifyEmpty(form.phone.value) && !VerifyPhoneNumLength(form.phone.value)) { ErrorText += "\u00B7 Hibás telefonszám! Kérjük adjon meg egy min. hétjegyű számot.\n"; isCorrect = false; } if (!isCorrect) { alert(ErrorText); } else { form.submit(); // return isCorrect; } }
|