function validate_form() {
  if (!check_empty(document.getElementById("contact_form").nume.value))
  	{ 
		document.getElementById("contact_form").nume.focus();
		alert('Campul Nume nu este completat!'); 
		return false;  
	}
  if (!check_empty(document.getElementById("contact_form").firma.value))
  	{ 
		document.getElementById("contact_form").firma.focus();
		alert('Campul Firma nu este completat!'); 
		return false;
	}
	if (!validateEmail(document.getElementById("contact_form").email))
  	{ 
		document.getElementById("contact_form").email.focus();
		return false;
	}
  if (!check_empty(document.getElementById("contact_form").adresa.value))
  	{ 
		document.getElementById("contact_form").adresa.focus();
		alert('Campul Adresa nu este completat!'); 
		return false;
	}
  if (!check_empty(document.getElementById("contact_form").oras.value))
  	{ 
		document.getElementById("contact_form").oras.focus();
		alert('Campul Oras nu este completat!'); 
		return false;
	}
  if (!check_empty(document.getElementById("contact_form").judet.value))
  	{ 
		document.getElementById("contact_form").judet.focus();
		alert('Campul Judet nu este completat!'); 
		return false; 
	}
  if (!check_empty(document.getElementById("contact_form").cod.value))
  	{ 
		document.getElementById("contact_form").cod.focus();
		alert('Campul Cod Postal nu este completat!'); 
		return false; 
	}
if (!check_empty(document.getElementById("contact_form").telefon.value))
  	{ 
		document.getElementById("contact_form").telefon.focus();
		alert('Campul Telefon nu este completat!'); 
		return false; 
	}
  return true;
}

function check_empty(text) {
  return (text.length > 0); // returns false if empty
}

function validateEmail(contr) {	

	if (contr.value=="") 	{

		alert("Va rugam sa introduceti adresa de email!");

		contr.focus();

		return false;	

	}		

	var tlds = ".ac .ad .ae .af .ag .ai .al .am .an .ao .aq .ar .as .at .au .aw .ax .az .ba .bb .bd .be .bf .bg .bh .bi .bj .bm .bn .bo .br .bs .bt .bu .bv .bw .by .bz .ca .cc .cd .cf .cg .ch .ci .ck .cl .cm	.cn .co .cr .cs .cu .cv .cx .cy .cz .dd .de .dj .dk .dm .do .dz .ec .ee .eg .eh .er .es .et .eu .fi .fj .fk .fm .fo .fr .ga .gb .gd .ge .gf .gg .gh .gi .gl .gm .gn .gp .gq .gr .gs .gt .gu .gw .gy .hk .hm .hn .hr .ht .hu .id .ie .il .im .in .io .iq .ir .is .it .je .jm .jo .jp .ke .kg .kh .ki .km .kn .kp .kr .kw .ky .kz .la .lb .lc .li .lk .lr .ls .lt .lu .lv .ly .ma .mc .md .mg .mh .mk .ml .mm .mn .mo .mp .mq .mr .ms .mt .mu .mv .mw .mx .my .mz .na .nc .ne .nf .ng .ni .nl .no .np .nr .nu .nz .om .pa .pe .pf .pg .ph .pk .pl .pm .pn .pr .ps .pt .pw .py .qa .re .ro .ru .rw .sa .sb .sc .sd .se .sg .sh .si .sj .sk .sl .sm	.sn .so .sr .st .su .sv .sy .sz .tc .td .tf .tg .th .tj .tk .tl .tm .tn .to .tp .tr .tt .tv .tw .tz .ua .ug .uk .um .us .uy .uz .va .vc .ve .vg .vi .vn .vu .wf .ws .ye .yt .yu .za .zm .zr .zw .com .net .org .mil .gov .edu .nato .info .int .name .biz .museum .pro";	

	

	var myRegex = new RegExp("^[A-Za-z0-9\-\._]+@[A-Za-z0-9\-\._]+\.[A-Za-z]+$");

	var endofString = contr.value.split('.');

	var ending = endofString.length - 1;

	var tld = endofString[ending];

	

	if (! contr.value.match(myRegex))	{

		alert("Va rugam sa introduceti adresa de email!");

		contr.focus();

		return false;	

	}	

	else		

		if (tlds.search(tld) < 0) {				

			alert("Va rugam sa introduceti adresa de email!");

			contr.focus();

			return false;

		}

	return true;

}























