
var r=
{
  'special':/[\W]/g,
  'quotes':/['\''&'\"']/g,
  'notnumbers':/[^\d]/g
}

function valid(o,w)
{
  o.value = o.value.replace(r[w],'');
}

function trim(stringToTrim)
{
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function Validate()
{
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

    var address = document.nanakshahi.vaddress.value;
    var city = document.nanakshahi.vcity.value;
    var country = document.nanakshahi.vcountry.value;
    var phone = document.nanakshahi.vphone.value;
    var email = document.nanakshahi.vemail.value;
    var name = document.nanakshahi.vname.value;
    var mobile = document.nanakshahi.vmobile.value;
    var venue = document.nanakshahi.vvenue.value;
    var sdate = document.nanakshahi.vstartdate.value;
    //var stime = document.nanakshahi.vstarttime.value;
    var edate = document.nanakshahi.venddate.value;
    //var etime = document.nanakshahi.vendtime.value;
    var capele = document.getElementById("recaptcha_response_field");

    address = trim(address);
    city = trim(city);
    country = trim(country);
    phone = trim(phone);
    email = trim(email);
    name = trim(name);
    mobile = trim(mobile);
    venue = trim(venue);
    sdate = trim(sdate);
    //stime = trim(stime);
    edate = trim(edate);
    //etime = trim(etime);

    var captcha = trim(capele.value);

   if(address.length<=4)
   {
       alert("Address seems to be invalid. Please fill it correctly.");
       document.nanakshahi.vaddress.focus();
       return false;
   }

   if(city.length<=3)
   {
       alert("City name seems to be invalid. Try again");
       document.nanakshahi.vcity.focus();
       return false;
   }

   if(country=='Unknown')
   {
       alert("Please select your country");
       document.nanakshahi.vcountry.focus();
       return false;
   }

   if(phone.length<=5)
   {
       alert("Please correctly fill your official phone number");
       document.nanakshahi.vphone.focus();
       return false;
   }

    if(email.length<=7)
    {
       alert("Email address needs to be corrected");
       document.nanakshahi.vemail.focus();
       return false;
    }
    else
    {
       if(reg.test(email) == false) 
       {
          alert("Invalid Email Address");
          document.nanakshahi.vemail.focus();
          return false;
       }
    }

   if(!name.match(/^[a-z A-Z]+$/))
   {
        alert("Need to fill in your name correctly");
        document.nanakshahi.vname.focus();
        return false;
   }

   if(mobile.length<=9)
   {
       alert("Please correctly fill your mobile number");
       document.nanakshahi.vmobile.focus();
       return false;
   }

   if(venue.length<=10)
   {
       alert("Please mention the venue correctly");
       document.nanakshahi.vvenue.focus();
       return false;
   }

   if(sdate.length<=7)
   {
       alert("Exhibition start date is invalid. Use date picker via click");
       document.nanakshahi.vstartdate.focus();
       return false;
   }

//   if(stime.length<=3)
//   {
//       alert("Exhibition start time is invalid. Do mention AM or PM along with time");
//       document.nanakshahi.vstarttime.focus();
//       return false;
//   }

   if(edate.length<=7)
   {
       alert("Exhibition end date is invalid. Use date picker via click");
       document.nanakshahi.venddate.focus();
       return false;
   }

//   if(etime.length<=3)
//   {
//       alert("Exhibition end time is invalid. Do mention AM or PM along with time");
//       document.nanakshahi.vendtime.focus();
//       return false;
//   }

   if(captcha.length<=5)
   {
       alert("Please fill in the words displayed in the image at bottom");
       capele.focus();
       return false;
   }
   return true;
}
