function checkEmail(str){ var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; if (filter.test(str)){ return true; }else{ return false; } } function subme(modulo) { var errors=''; ook=true; if (modulo.firstname.value=="") { errors+='- Ime\n'; ook=false; }; if (modulo.realname.value=="") { errors+='- Prezime\n'; ook=false; }; if (!checkEmail(modulo.email.value)) { errors+='- Please insert a valid email address\n'; ook=false; }; if (!(modulo.Privacy.checked)) { errors+='\n'+'- Privacy policy is required\n'; ook=false; }; if (!ook) { alert('The following fields are required:\n\n'+errors); } return ook; }