﻿// JScript File

function check_login_form() {

  var emailaddress = document.getElementById('ctl00_txtemail').value;
  var password = document.getElementById('ctl00_txtpassword').value;

  if (emailaddress == "" || emailaddress.length < 6) {
    error_message = "* The 'E-Mail Address' must have atleast 6 characters.\n";
    alert(error_message);
    document.getElementById('ctl00_txtemail').focus();
    return false;
  }

  if ((password == "" || password.length < 5)) {
    error_message = "* The 'Password' must have atleast 5 charactersaa.\n";
    alert(error_message);
    document.getElementById('ctl00_txtpassword').focus();
    return false;
  }

  // code to check valid email-id
  if (emailaddress.length != 0) { 
	if(emailaddress.indexOf("@") == -1) {
	  alert("Invalid E-Mail! Kindly enter correct E-mail address.");
      document.getElementById('ctl00_txtemail').focus();
	  return false;
	}    
   	validarr = emailaddress.split("@");
   
   	if(validarr[0].length==0) {
   	  alert("Invalid E-Mail! Kindly enter the correct E-mail address.");
      document.getElementById('ctl00_txtemail').focus();
   	  return false;
   	}
  	if(validarr[1].indexOf("@") >=0) {
   	  alert("Invalid E-Mail Format! Kindly enter the correct E-mail address.");
      document.getElementById('ctl00_txtemail').focus();
   	  return false;
   	}
   	if(validarr[1].length==0) {
   	  alert("Invalid E-Mail! Kindly enter the correct E-mail address.");
      document.getElementById('ctl00_txtemail').focus();
   	  return false;
   	}
   	if(validarr[1].length != 0) { 
      if(validarr[1].indexOf(".") == -1) {
  		alert("Invalid E-Mail Format! Kindly enter the correct E-mail address.");
        document.getElementById('ctl00_txtemail').focus();
   		return false;
 	  }
      validemail = validarr[1].split(".");
      if(validemail[0].length==0) { 
        alert("Invalid E-Mail! Kindly enter the correct E-mail address.");
        document.getElementById('ctl00_txtemail').focus();
       	return false;
      }
      if(validemail[1].length==0) {
        alert("Invalid E-Mail! Kindly enter the correct E-mail address.");
        document.getElementById('ctl00_txtemail').focus();
       	return false;
	  }
    }   // end of of validemail
  } // end of valid email-id check
}


function validateit(theForm)
{
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(theForm.email.value)))
	{
		alert("Invalid Email ID. Kindly enter the correct ID.");
		theForm.email.focus();
		return (false);
	}
}
