﻿ //JScript File
/******************************************************
Method Name	:	fnInputValidator(current,val)
Creator		:	Tamilavel.S
Date		:	13-Jan-2009
Description	:	This method us a general method for 
                validating phone,number and alphabets.
*******************************************************/
var phone = "()- 0123456789";
var number ="0123456789";
var rate = "0123456789.";
var date = "0123456789/";
var accessno ="0123456789-";
var alphabets ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var alpha ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,/&";
var alphaedu ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,&/";
var alphaname ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .";
function fnInputValidator(current,val)
{
    var result = "";
    for (i=0; i < current.value.length; i++) 
    {
        conString = current.value.charAt(i);
        if (val.indexOf(conString,0) != -1)
            result += conString;
    }
    current.value = result;
   
}

//Function  for Email Validation
//=============================

function checkEmail(myForm) 
{

  if (myForm.value=="") 
    {
      return (true);
    }

if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.value))
{
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
myForm.value="";
myForm.focus();
return (false)
}

//function for checkempty
function checkEmpty(myForm)
{
if (myForm.value=="")
{
return (true)
}
alert ("Enter Order Ref.No")
myForm.valueOf="";
myForm.focus();
return (false)
}

// function for compare year

 function CheckFromYear(ctrl)
    {
        var CtrlId=ctrl.id;
        if(document.getElementById(CtrlId).value!='' && document.getElementById(CtrlId).value < 1950)
        {
            alert('From year should be > 1950!');
            document.getElementById(CtrlId).focus();
        }
    }
    function CheckToYear(ctrl)
    {
        var FromCtrlId=ctrl.id;
        FromCtrlId=FromCtrlId.replace('To','From');
        var ToCtrlId=ctrl.id;
        
        var Dt = new Date();
        var CurYear = Dt.getFullYear();
        
        var ToYear = document.getElementById(ToCtrlId).value;
        var FromYear = document.getElementById(FromCtrlId).value;
        if(document.getElementById(FromCtrlId).value!='' && document.getElementById(FromCtrlId).value>1950)
        {
            if(ToYear>CurYear)
            {
                alert('To Year should be <= current year!');
               document.getElementById('txtToYear1').focus();
            }
            if(ToYear<FromYear)
            {
                alert('To Year should be >= From year!');
               // document.getElementById('txtToYear1').focus()    
              
            }
        }
        if(document.getElementById(ToCtrlId).value!='' && document.getElementById(FromCtrlId).value=='')
        {
            alert('Please enter the From year!');
        }
    }   

///////////////////////////////////////////////////////////////////////////////////////


