﻿// JavaScript Document
// JavaScript Document

function valid(form) {
  var field = trim(form.email); // email field

  var str = field.value; // email string

  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid

  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid

  if (trim(form.name.value) == "") {

  	alert("نام خود را وارد نمایید.");

	form.name.focus();

	form.name.select();

  	return false;

  }
  
   if (trim(form.age.value) == "") {

  	alert(".");

	form.age.focus();

	form.age.select();

  	return false;

  }
  if (!reg1.test(str) && reg2.test(str)) {

  }

  else {

  	alert("آدرس" + "\"" + str + "\"" + "معتبر نمي باشد."); // this is also optional

	field.focus();

	field.select();

  	return false;

  }
  
  if (trim(form.country.value) == "") {

  	alert("کشور خود را وارد نمایید.");

	form.age.focus();

	form.age.select();

  	return false;

  }
  if (trim(form.question.value) == "") {

  	alert("سوال خود را وارد نمایید.");

	form.content.focus();

	form.content.select();

  	return false;

  }

  

}




