﻿// JScript File

function checkForm(frm)
{
var lblError = document.getElementById("lblError");
//array that holds the form elements
var e = frm.elements;
var Emailpat = new RegExp("^([a-zA-Z0-9_\\-\\.-]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");//regex for Email
//checking if the required fields are filled and comparing them to the regular expressions
for (var i=0; i<e.length;i++)
{

if (emptyField(e[i]))
{

}
switch (e[i].id)
{

case "Email":
if (!Emailpat.test(e[i].value))
  { 
  lblError.style.visibility = "visible";
  lblError.innerHTML = "Invalid EMail address";
  e[i].focus();
  return false;
  }

  
}

}

}
function emptyField(textObj)
{
	if (textObj.value.length == 0) return true;
	for (var i=0; i<textObj.value.length; i++) 
	{
		var ch = textObj.value.charAt(i);
		if (ch != ' ' && ch != '\t') return false;	
	}
	
}
