Function to compaire Two dates
****************************************************************************
function DateValidate(CtrlSDate, CtrlEDate)
{
**Starting date
var SDate = document.getElementById(CtrlSDate).value;
**Ending date
var EDate = document.getElementById(CtrlEDate).value;
var firstIndex = SDate.indexOf("-");
var secondIndex = SDate.lastIndexOf("-");
var d1 = SDate.substring(0,firstIndex);
var m1 = SDate.substring(firstIndex+1,secondIndex);
var y1 = SDate.substring(secondIndex+1,SDate.length);
var SDateFull=m1 + "/" + d1 + "/" +y1;
var d2 = EDate.substring(0,firstIndex);
var m2 = EDate.substring(firstIndex+1,secondIndex);
var y2 = EDate.substring(secondIndex+1,EDate.length);
var EDateFull=m2 + "/" + d2 + "/" +y2;
var startDate = new Date(SDateFull);
var endDate = new Date(EDateFull);
if(SDate != '' && EDate != '' && startDate > endDate)
{
alert('TO date must be greater than FROM date.');
return false;
}
return true;
}
****************************************************************************
function swap_color( obj )
{
return obj.style.backgroundColor = '#FFFFCC' ;
}
function swap_color_back( obj )
{
return obj.style.backgroundColor = 'white' ;
}
function Calculate_Term()
{
var NOD= document.getElementById("").value;
var perAmt = document.getElementById("").value;
if (NOD.length>0 && perAmt.Length>0)
{
document.getElementById("").value=perAmt & '% of ' & NOD &' days';
}
return obj.style.backgroundColor = 'white' ;
}
function IsDecimal(text)
{
var strString =text.value
var strValidChars = "0123456789.";
var strChar;
for (i = 0; i < strchar =" strString.charAt(i);" value =" text.value.substring(0,i);" strstring ="text.value" strvalidchars = "0123456789" i =" 0;" strchar =" strString.charAt(i);" value =" text.value.substring(0,i);" strstring ="text.value" strvalidchars =" ">";
var strChar;
for (i = 0; i < strchar =" strString.charAt(i);"> -1)
{
text.value = text.value.substring(0,i);
return false;
}
}
}
function Check_Max(text,long)
{
var maxlength = new Number(long);
if(text.value.length > maxlength)
{
text.value = text.value.substring(0,maxlength);
}
}
function SelectAllCheckboxes(spanChk)
{
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox= (spanChk.type=="checkbox") ?
spanChk : spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i
}
// All characters are numbers.
return true;
}
function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < c =" s.charAt(i);" 4 ="="" 100 ="="" 400 ="="" i =" 1;" i="="4" i="="6" i="="9" i="="11)" i="="2)" daysinmonth =" DaysArray(12)" pos1="dtStr.indexOf(dtCh)" pos2="dtStr.indexOf(dtCh,pos1+1)" strmonth="dtStr.substring(pos1+1,pos2)" strday="dtStr.substring(0,pos1)" stryear="dtStr.substring(pos2+1)" stryr="strYear">1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)
if (pos1==-1 pos2==-1){
alert("The date format should be : dd/mm/yyyy")
return false
}
if (strMonth.length<1>12){
alert("Please enter a valid month")
return false
}
if (strDay.length<1>31 (month==2 && day>daysInFebruary(year)) day > daysInMonth[month]){
alert("Please enter a valid day")
return false
}
if (strYear.length != 4 year==0 year
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date")
return false
}
return true
}
function ValidateForm(Obj)
{
//var dt=document.frmSample.txtDate
var dt=Obj;
if (dt.value=="")
{
}
else
{
if (isDate(dt.value)==false){
dt.focus()
}
}
return dt.style.backgroundColor = 'white' ;
}
function Is_Date(Obj)
{
//var dt=document.frmSample.txtDate
var dt=Obj;
if (dt.value=="")
{
}
else
{
if (isDate(dt.value)==false){
dt.focus()
}
}
return dt.style.backgroundColor = 'white' ;
}
Read Max Length Of The Control
function checkTextAreaMaxLength(textBox,e, length)
{
var mLen = textBox["MaxLength"];
if(null==mLen)
mLen=length;
var maxLength = parseInt(mLen);
if(!checkSpecialKeys(e))
{
if(textBox.value.length > maxLength-1)
{
if(window.event)//IE
e.returnValue = false;
else//Firefox
e.preventDefault();
}
}
}
Read Extension Of The Uploaded File
function checkextension(msg)
{
document.getElementById(msg).style.display = 'none';
if(document.getElementById("").value !="" && document.getElementById("").value.lastIndexOf(".doc")==-1)
{
alert("Please upload only .doc extension file");
document.getElementById("").focus();
}
}
Read Special Keys
function checkSpecialKeys(e)
{
if(e.keyCode !=8 && e.keyCode!=46 && e.keyCode!=37 && e.keyCode!=38 && e.keyCode!=39 && e.keyCode!=40)
return false;
else
return true;
}
Remove Blank WhiteSpace
function LTrim( value )
{
var re = /\s*((\S+\s*)*)/;
return value.replace(re, "$1");
}
// Removes ending whitespaces
function RTrim( value )
{
var re = /((\s*\S+)*)\s*/;
return value.replace(re, "$1");
}
// Removes leading and ending whitespaces
function trim( value )
{
return LTrim(RTrim(value));
}
*********************************************************
ConversionConversion EmoticonEmoticon