function checknum(checkStr){
  var checkOK = "0123456789-.,";
  //var checkStr = theForm.txtdupSSN3.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters.");
    //theForm.txtdupSSN3.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
  	msg = 2
    alert("Please enter a valid number.");
    //theForm.txtdupSSN3.focus();
    return (false);
  }
}
function checkqty(checkStr){
  var checkOK = "0123456789";
  //var checkStr = theForm.txtdupSSN3.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters.");
    //theForm.txtdupSSN3.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
  	msg = 2
    alert("Please enter a valid number.");
    //theForm.txtdupSSN3.focus();
    return (false);
  }
}

function validemail(email)
{	

	pose=email.indexOf('@');
	posd=email.indexOf('.');
	len=email.length;
//alert(len);
	if (pose==-1)//to check the existence of @
	{
		alert("E-mail should contain '@' ");
		return false;	
	}

	subemail=email.substring(1,pose);
	dotin = subemail.indexOf('.');
	count = 0;
	dotin = subemail.indexOf('.');
//	pos = str.indexOf("x");
	while ( dotin != -1 ) {
	   count++;
	   dotin = subemail.indexOf(".",dotin+1);
	}
//	alert(count)
	if (count > 2)
	{
		alert("Only Two Dot is allowed before '@'.");
		return false;
	}
//return false;
//	alert(subemail + " " + coun)	;
//	if (email.indexOf('.')==-1 || email.indexOf('.')==0 || email.indexOf('.')==len){
//	if(subemail.indexOf('.')!=subemail.lastIndexOf('.'))//to check the existence of . before @
//	{
//		alert("Only One Dot is allowed before '@' ");
//		return false;
//	}
	
	if (email.indexOf('@')!=email.lastIndexOf('@')) //to check the number of existence of @ in the email field"
	{
		alert("Only one @ is allowed in the E-mail field.");
		return false;
	}
		
	if ((subemail.length)<2)//To check the num.of characters before @
	{
		alert("There must be more than 2 characters beore '@' ");
		return false;
	}
	
	fchar=email.charCodeAt(0);
	if((fchar < 48 && fchar > 57) || (fchar > 57 && fchar < 65) || (fchar>90 && fchar<97) || fchar>122)//to check the existence of alphabets in the first character of the email
	{
		alert("Ist character in the E-mail should be an alphabet.");
		return false;
	}
	
	//x=email.substring(0,e);
	for (i=0;i<subemail.length;i++)//to check the character validation before the @
	{
		//if ((subemail.charCodeAt(i)<65 || subemail.charCodeAt(i)>90) && (subemail.charCodeAt(i)<97 || subemail.charCodeAt(i)>122)  && (subemail.charCodeAt(i)<44 || subemail.charCodeAt(i)==46 || subemail.charCodeAt(i)==47 || subemail.charCodeAt(i)>57) && (subemail.charCodeAt(i)!=95))
		if ((subemail.charCodeAt(i)<65 || subemail.charCodeAt(i)>90) && (subemail.charCodeAt(i)<97 || subemail.charCodeAt(i)>122)  && (subemail.charCodeAt(i)<44 || subemail.charCodeAt(i)==47 || subemail.charCodeAt(i)>57) && (subemail.charCodeAt(i)!=95))
		{
			alert("Invalid entry in the E-mail field.");
			return false;
		}
	}
	
	str=email.substr(pose+1,len);
	if(str.length<6)//to check the number of entries after @
	{
		alert("Invalid E-mail Address.");
		return false;
	}
	
	if(str.indexOf('.')==-1)//to check the existence of dot after @
	{
		alert("There must a dot after @ in the E-mail field.");
		return false;
	}
	
	tempstr=email.substr(pose+1);
	tempstr=tempstr + "."
	h=len;
	while(tempstr!="")
	{
		h=tempstr.indexOf('.');
		temp=tempstr.substr(0,h);
		if(temp.length<2)
		{
			alert("Invalid E-mail Address.");
			return false;
		}
		for (i=0;i<temp.length;i++)//to check the character validation after the @
		{
			//if ((temp.charCodeAt(i)<65 || temp.charCodeAt(i)>90) && (temp.charCodeAt(i)<97 || temp.charCodeAt(i)>122)  && (temp.charCodeAt(i)<44 || temp.charCodeAt(i)==46 || temp.charCodeAt(i)==47 || temp.charCodeAt(i)>57) && (temp.charCodeAt(i)!=95))
			if ((temp.charCodeAt(i)<65 || temp.charCodeAt(i)>90) && (temp.charCodeAt(i)<97 || temp.charCodeAt(i)>122)  && (temp.charCodeAt(i)<44 || temp.charCodeAt(i)==46 || temp.charCodeAt(i)==47 || temp.charCodeAt(i)>57) && (temp.charCodeAt(i)!=95))
			{
				alert("Invalid entry in the E-mail field.");
				return false;
			}
		}
		tempstr=tempstr.substr(h+1);
	}
	return true;
}
function validemail_test(email)
{	
	pose=email.indexOf('@');
	posd=email.indexOf('.');
	len=email.length;
//alert(len);
	if (pose==-1)//to check the existence of @
	{
		alert("E-mail should contain '@' ");
		return false;	
	}

	subemail=email.substring(1,pose);
	dotin = subemail.indexOf('.');
	count = 0;
	dotin = subemail.indexOf('.');
//	pos = str.indexOf("x");
	while ( dotin != -1 ) {
	   count++;
	   dotin = subemail.indexOf(".",dotin+1);
	}
//	alert(count)
	if (count > 2)
	{
		alert("Only Two Dot is allowed before '@'.");
		return false;
	}
//return false;
//	alert(subemail + " " + coun)	;
//	if (email.indexOf('.')==-1 || email.indexOf('.')==0 || email.indexOf('.')==len){
//	if(subemail.indexOf('.')!=subemail.lastIndexOf('.'))//to check the existence of . before @
//	{
//		alert("Only One Dot is allowed before '@' ");
//		return false;
//	}
	
	if (email.indexOf('@')!=email.lastIndexOf('@')) //to check the number of existence of @ in the email field"
	{
		alert("Only one @ is allowed in the E-mail field.");
		return false;
	}
		
	if ((subemail.length)<2)//To check the num.of characters before @
	{
		alert("There must be more than 2 characters beore '@' ");
		return false;
	}
	
	fchar=email.charCodeAt(0);
	if(fchar<65 || (fchar>90 && fchar<97) || fchar>122)//to check the existence of alphabets in the first character of the email
	{
		alert("Ist character in the E-mail should be an alphabet.");
		return false;
	}
	
	//x=email.substring(0,e);
	for (i=0;i<subemail.length;i++)//to check the character validation before the @
	{
		if ((subemail.charCodeAt(i)<65 || subemail.charCodeAt(i)>90) && (subemail.charCodeAt(i)<97 || subemail.charCodeAt(i)>122)  && (subemail.charCodeAt(i)<46 || subemail.charCodeAt(i)==47 || subemail.charCodeAt(i)>57) && (subemail.charCodeAt(i)!=95))
		{
			alert("Invalid entry in the E-mail field.");
			return false;
		}
	}
	
	str=email.substr(pose+1,len);
	if(str.length<6)//to check the number of entries after @
	{
		alert("Invalid E-mail Address.");
		return false;
	}
	
	if(str.indexOf('.')==-1)//to check the existence of dot after @
	{
		alert("There must a dot after @ in the E-mail field.");
		return false;
	}
	
	tempstr=email.substr(pose+1);
	tempstr=tempstr + "."
	h=len;
	while(tempstr!="")
	{
		h=tempstr.indexOf('.');
		temp=tempstr.substr(0,h);
		if(temp.length<2)
		{
			alert("Invalid E-mail Address.");
			return false;
		}
		for (i=0;i<temp.length;i++)//to check the character validation after the @
		{
			if ((temp.charCodeAt(i)<65 || temp.charCodeAt(i)>90) && (temp.charCodeAt(i)<97 || temp.charCodeAt(i)>122)  && (temp.charCodeAt(i)<48 || temp.charCodeAt(i)>57) && (temp.charCodeAt(i)!=95)&&(temp.charCodeAt(i)!=45))
			{
				alert("Invalid entry in the E-mail field.");
				return false;
			}
		}
		tempstr=tempstr.substr(h+1);
	}
	return true;
}