Javascript file
// JScript File
//Rollover images code
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//Rollover images code ends.
//Java Script for the validation
var otherValidation;
var hdnValidationFld;
var errorRow
function Validator(frmname,btnname,otherValidatio,hdnValidationFlag,errorMessageRow)
{
otherValidation=otherValidatio;
hdnValidationFld=hdnValidationFlag;
errorRow=errorMessageRow;
this.formobj=document.forms[frmname];
if(!this.formobj)
{
alert("BUG: couldnot get Form object "+frmname);
return;
}
this.btnobj = this.formobj[btnname];
if(!this.btnobj)
{
this.btnobj=document.getElementById(btnname);
}
if(!this.btnobj)
{
//alert("BUG: couldnot get object "+btnname);
return;
}
if(this.formobj.onsubmit)
{
this.formobj.old_onsubmit = this.formobj.onsubmit;
this.formobj.onsubmit=null;
}
else
{
this.formobj.old_onsubmit = null;
}
this.btnobj.onclick=form_submit_handler;
this.addValidation = add_validation;
this.setAddnlValidationFunction=set_addnl_vfunction;
this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
var elem = document.getElementById('aspnetForm').elements;
for(var itr=0;itr < elem.length;itr++)
{
elem[itr].validationset = null;
}
}
function form_submit_handler()
{
if(otherValidation!='')
{
if(eval(otherValidation)==false)
{
return false;
}
}
for(var itr=0;itr < document.aspnetForm.elements.length;itr++)
{
if(document.aspnetForm.elements[itr].validationset &&
!document.aspnetForm.elements[itr].validationset.validate())
{
return false;
}
}
// if(document.aspnetForm.elements[itr].addnlvalidation)
// {
// str =" var ret = "+document.aspnetForm.elements[itr].addnlvalidation+"()";
// eval(str);
// if(!ret) return ret;
// }
return true;
}
function add_validation(itemname,descriptor,errstr)
{
if(!this.formobj)
{
//alert("BUG: the form object is not set properly");
return;
}//if
var itemobj = this.formobj[itemname];
if(!itemobj)
itemobj =document.getElementById(itemname);
if(!itemobj)
{
//alert("BUG: Couldnot get the input object named: "+itemname);
return;
}
// alert(itemname);///////////////////////////////////////
if(!itemobj.validationset)
{
itemobj.validationset = new ValidationSet(itemobj);
}
itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
this.desc=desc;
this.error=error;
this.itemobj = inputitem;
this.validate=vdesc_validate;
}
function vdesc_validate()
{
if(!V2validateData(this.desc,this.itemobj,this.error))
{
if(!this.itemobj.disabled)
this.itemobj.focus();
return false;
}
return true;
}
function ValidationSet(inputitem)
{
this.vSet=new Array();
this.add= add_validationdesc;
this.validate= vset_validate;
this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
this.vSet[this.vSet.length]=
new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
for(var itr=0;itr<this.vSet.length;itr++)
{
if(!this.vSet[itr].validate())
{
return false;
}
}
return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking.
// you can add more complex email checking if it helps
if(email.length <= 0)
{
return true;
}
else
{
var regexp_user=/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
if(email.match(regexp_user) == null)
{
return false;
}
}
return true;
} //end of function
function checkDomain(nname)
{
var mai = nname;
var val = true;
var htp7="http://";
//var htp6="http:/";
//var htp5="http:";
var http7=mai.substring(0,7);
//var http6=mai.substring(0,6);
//var http5=mai.substring(0,5);
//var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,mai.length);
//var ext = mai.substring(dot,mai.length);
//alert(dname);
if(dname.length>7 && dname.length<200)
{
for(var i=0; i<1; i++)
{
if(dname.length>7 && dname.length<200)
{
val = true;
// alert("Your domain rect");
break;
}
else
{
val = false;
// alert("Your domain correct");
}
if(val == false)
{
//alert("Your domain extension "+ext+" is not correct");
return false;
}
}
}
else
{
//alert("Your Domain name is too short/long");
return false;
}
return true;
}//end of function
function IsImage(oObject)
{
var ext=trim(oObject.value);
if(ext.length>0)
{
ext = ext.substring(ext.length-3,ext.length);
ext = ext.toLowerCase();
if(ext != 'jpg'&& ext != 'gif' && ext != 'bmp' && ext != 'jpeg')
{
//alert('You selected a .'+ext+' file; please select a image file instead!');
return false;
}
else
return true;
}
return true;
}
function V2validateData(strValidateStr,objValue,strError)
{
var epos = strValidateStr.search("=");
var command = "";
var cmdvalue = "";
var objErrorLbl;
// document.getElementById(hdnValidationFld).value="A";
objErrorLbl=document.getElementById(errorRow);
//alert(document.getElementById(hdnValidationFld).value)//.value=strError;
if(epos >= 0)
{
command = strValidateStr.substring(0,epos);
cmdvalue = strValidateStr.substr(epos+1);
}
else
{
command = strValidateStr;
}
//compare
var compControl2=""
if(command=="dateDifference")
{
var arr = strError.split("|")
strError = arr[1];
stopDateControl = arr[0];
}
if(command=="compare")
{
var arr = strError.split("|")
strError = arr[1];
compControl2 = arr[0];
}
if(command=="comp")
{
var arr = strError.split("|")
strError = arr[1];
compControl2 = arr[0];
}
if(command=="less")
{
var arr = strError.split("|")
strError = arr[1];
compControl2 = arr[0];
}
//compare
var compControlSecond=""
if(command=="compareSecondControlGreater")
{
var arr = strError.split("|")
strError = arr[1];
//alert("strError:" +strError);
compControlSecond = arr[0];
}
switch(command)
{
case "PhoneNumberValidation":
{
var PhonePat = /^\d{14}$/;
var matchArray = objValue.value.match(PhonePat);
if (matchArray == null)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Only alpha-numeric characters allowed ";
}//if
//alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
objErrorLbl.innerHTML = strError;
return false;
}
break;
}
case "select Genre":
case "Select Status":
case "Select User":
case "Select":
case "Select a content Type":
{ //alert(objValue);
if( objValue.options[objValue.selectedIndex].text =="Select Status"
|| objValue.options[objValue.selectedIndex].text =="Select User"
|| objValue.options[objValue.selectedIndex].text =="Select a content Type"
|| objValue.options[objValue.selectedIndex].text =="Select"
|| objValue.options[objValue.selectedIndex].text =="Select Genre")
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " Passwords not matched!!";
}
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case compare
case "dateDifference":
{
var exp=document.getElementById(stopDateControl);
if(exp.value.length!=0 && objValue.value.length!=0)
{
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})\s*$/;
var blnIsValid=false;
var matchArray = objValue.value.match(datePat);
if (matchArray == null)
{ objErrorLbl.innerHTML = strError;
return false;
}
day1 = matchArray[1]; // parse date into variables
month1 = matchArray[3];
year1 = matchArray[4];
var matchArray = exp.value.match(datePat);
day2 = matchArray[1]; // parse date into variables
month2 = matchArray[3];
year2 = matchArray[4];
if(year1>year2)
{
blnIsValid=false;
}
else if(year1<year2)
{
blnIsValid=true;
}
else if(year1==year2)
{
if(month1>month2)
{
blnIsValid=false;
}
else if(month1<month2)
{
blnIsValid=true;
}
else if(month1==month2)
{
if(day1>=day2)
{
blnIsValid=false;
}
else if(day1<day2)
{
blnIsValid=true;
}
}
}
if(!blnIsValid)
{
objErrorLbl.innerHTML = strError;
return false;
}
}
break;
}
case "Image":
case "image":
{
if(!IsImage(objValue))
{
// alert(IsImage(objValue));
return false
}
break;
//IsImage
}
case "comp":
{ //alert(trim(objValue.value))
if(trim(objValue.value) == document.getElementById(compControl2).value)
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " Passwords not matched!!";
}//if
document.getElementById(compControl2).focus();
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case compare
case "less":
{ //alert(trim(objValue.value))
if(trim(objValue.value) <= document.getElementById(compControl2).value)
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " Passwords not matched!!";
}//if
document.getElementById(compControl2).focus();
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case compare
case "compare":
{ //alert(trim(objValue.value))
if(trim(objValue.value) != document.getElementById(compControl2).value)
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " Passwords not matched!!";
}//if
document.getElementById(compControl2).focus();
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case compare
case "compareSecondControlGreater":
{ //alert(trim(objValue.value))
//alert("compareSecondControlGreater");
var txtValue1=0;
var txtValue2=0;
txtValue1=parseInt(trim(objValue.value));
txtValue2=parseInt(trim(document.getElementById(compControlSecond).value));
if(txtValue1 >= txtValue2)
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " should be less than " + compControlSecond.name + "!!";
}//if
document.getElementById(compControlSecond).focus();
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}
case "req":
case "required":
{ //alert(trim(objValue.value))
// var dir=document.all ? document.all['ctl00_ContentPlaceHolder1_divError'] : document. getElementById('ctl00_ContentPlaceHolder1_divError');
// alert(dir.innerHtml);
if(eval(trim(objValue.value).length) == 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : Required Field1";
}
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case required
case "ItemCount":
{
if(objValue.options.length == 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : Required Field1";
}
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case required
case "maxlength":
case "maxlen":
{
if(eval(objValue.value.length) > eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : "+cmdvalue+" characters maximum ";
}//if
//alert(strError + "\n[Current length = " + objValue.value.length + " ]");
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case maxlen
case "minlength":
case "minlen":
{
if(eval(objValue.value.length)>0)
{
if(eval(objValue.value.length) < eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : " + cmdvalue + " characters minimum ";
}//if
objErrorLbl.innerHTML = strError;
return false;
}//if
}
break;
}//case minlen
case "alnum":
case "alphanumeric":
{
var dataValue= trim(objValue.value);
var charpos = dataValue.search("[^A-Za-z0-9 ]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Only alpha-numeric characters allowed ";
}//if
//alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case alphanumeric
case "num":
case "numeric":
{
var charpos = objValue.value.search("[^0-9]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Only digits allowed ";
}//if
//alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//numeric
case "alphabetic":
case "alpha":
{
var charpos = objValue.value.search("[^A-Za-z ]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Only alphabetic characters allowed ";
}//if
//alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
alert(strError);
return false;
}//if
break;
}//alpha
case "alnumhyphen":
{
var charpos = objValue.value.search("");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _";
}//if
// alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}
case "phone":
case "PHONE":
{
var charpos = objValue.value.search("[^0-9\-+()/. ]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": characters allowed are 0-9,-,/,.,+,()";
}//if
// alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}
case "password":
case "PASSWORD":
{
//alert('password');
//alert(objValue.value);
//var re= /^\w*(?=\w*\d)(?=\w*[a-z\W])(?=\w*[A-Z])\w*$/;
// var re= /^.*(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*+=]).*$/;
var re=/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{1,}$/;
// var re = "[a-zA-Z0-9\W\S\s\w]+$";
// alert(re.test("objValue.value"));
var charpos = objValue.value.search(re);
if(objValue.value.length >= 0 && charpos < 0)
{
// alert(charpos);
if(!strError || strError.length ==0)
{
strError = objValue.name+": characters allowed are A-Z a-z 0-9";
}//if
//alert(strError + "\n [Error character position " + eval(charpos+1)+"]");
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}
case "email":
{
var emaildata=trim(objValue.value);
if(!validateEmailv2(emaildata))
{
if(!strError || strError.length ==0)
{
strError = " Enter a valid Email address ";
}
objErrorLbl.innerHTML = strError;
return false;
}
break;
}//case email
case "Website":
{
if(!checkDomain(objValue.value))
{
if(!strError || strError.length ==0)
{
strError = " Enter a valid Web Site name ";
}//if
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case Website
case "NoOfAbuse":
{ //alert(trim(objValue.value))
var ddlAbuse=document.getElementById('ctl00_ContentPlaceHolder1_ddlNoOfAbuses');
if(trim(ddlAbuse.value).length ==1 || trim(ddlAbuse.value).length ==2 )
{
var exp=document.getElementById('ctl00_ContentPlaceHolder1_txtNoOfAbuse');
//alert(exp);
if((exp.value).length ==0)
{
if(!strError || strError.length ==0)
{
strError = "Please enter No of Abuses";
}//if
objErrorLbl.innerHTML = strError;
return false;
}}//if
break;
}//case compare
case "RegisterdOperator":
{ //alert(trim(objValue.value))
var ddlRegisterd=document.getElementById('ctl00_ContentPlaceHolder1_ddlRegistered');
if(trim(ddlRegisterd.value).length ==5 || trim(ddlRegisterd.value).length ==2 || trim(ddlRegisterd.value).length ==7 )
{
var between="Between";
if(ddlRegisterd.value==between)
{
var exp=document.getElementById('ctl00_ContentPlaceHolder1_intxtRegistered');
var exp1=document.getElementById('ctl00_ContentPlaceHolder1_intxtStopRegisterd');
if((exp.value).length ==0)
{
if(!strError || strError.length ==0)
{
strError = "Please select Start Date";
}//if
objErrorLbl.innerHTML = strError;
return false;
}
if((exp1.value).length ==0)
{
if(!strError || strError.length ==0)
{
strError = "Please select Stop Date";
}//if
objErrorLbl.innerHTML = strError;
return false;
}
}
else
{
var exp=document.getElementById('ctl00_ContentPlaceHolder1_intxtRegistered');
// alert(exp);
if((exp.value).length ==0)
{
if(!strError || strError.length ==0)
{
strError = "Please select Start Date";
}//if
objErrorLbl.innerHTML = strError;
return false;
}
}
}//if
break;
}//case compare
case "lt":
case "lessthan":
{
if(isNaN(objValue.value))
{
//alert(objValue.name+": Should be a number ");
return false;
}//if
if(eval(objValue.value) >= eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name + " : value should be less than "+ cmdvalue;
}//if
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case lessthan
case "diffString":
{
var exp=document.getElementById('ctl00_ContentPlaceHolder1_txtStartDate');
if(exp.value.length!=0 && objValue.value.length!=0)
{
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})\s*$/;
var blnIsValid=false;
var matchArray = objValue.value.match(datePat);
if (matchArray == null)
{ objErrorLbl.innerHTML = strError;
return false;
}
day1 = matchArray[1]; // parse date into variables
month1 = matchArray[3];
year1 = matchArray[4];
var matchArray = exp.value.match(datePat);
day2 = matchArray[1]; // parse date into variables
month2 = matchArray[3];
year2 = matchArray[4];
if(year1<year2)
{
blnIsValid=false;
}
else if(year1>year2)
{
blnIsValid=true;
}
else if(year1==year2)
{
if(month1<month2)
{
blnIsValid=false;
}
else if(month1>month2)
{
blnIsValid=true;
}
else if(month1==month2)
{
if(day1<day2)
{
blnIsValid=false;
}
else if(day1>day2)
{
blnIsValid=true;
}
else if(day1==day2)
{
blnIsValid=true;
}
}
}
if(!blnIsValid)
{
objErrorLbl.innerHTML = strError;
return false;
}
// if(year2>year1)
// {
// objErrorLbl.innerHTML = strError;
// return false;
// }
// else if(month2>month1)
// {
// objErrorLbl.innerHTML = strError;
// return false;
// }
// else if(day2>day1)
// {
// objErrorLbl.innerHTML = strError;
// return false;
// }
}
break;
}
case "diffDate":
{
var exp=document.getElementById('ctl00_ContentPlaceHolder1_intxtRegistered');
if(exp.value.length!=0 && objValue.value.length!=0)
{
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})\s*$/;
var blnIsValid=false;
var matchArray = objValue.value.match(datePat);
if (matchArray == null)
{ objErrorLbl.innerHTML = strError;
return false;
}
day1 = matchArray[1]; // parse date into variables
month1 = matchArray[3];
year1 = matchArray[4];
var matchArray = exp.value.match(datePat);
day2 = matchArray[1]; // parse date into variables
month2 = matchArray[3];
year2 = matchArray[4];
if(year1<year2)
{
blnIsValid=false;
}
else if(year1>year2)
{
blnIsValid=true;
}
else if(year1==year2)
{
if(month1<month2)
{
blnIsValid=false;
}
else if(month1>month2)
{
blnIsValid=true;
}
else if(month1==month2)
{
if(day1<day2)
{
blnIsValid=false;
}
else if(day1>day2)
{
blnIsValid=true;
}
else if(day1==day2)
{
blnIsValid=true;
}
}
}
if(!blnIsValid)
{
objErrorLbl.innerHTML = strError;
return false;
}
// if(year2>year1)
// {
// objErrorLbl.innerHTML = strError;
// return false;
// }
// else if(month2>month1)
// {
// objErrorLbl.innerHTML = strError;
// return false;
// }
// else if(day2>day1)
// {
// objErrorLbl.innerHTML = strError;
// return false;
// }
}
break;
}
case "Search":
{
var txtUserName = document.getElementById('ctl00_ContentPlaceHolder1_txtUserName');
var txtEmail =document.getElementById('ctl00_ContentPlaceHolder1_txtEmail');
var ddlGenre =document.getElementById('ctl00_ContentPlaceHolder1_ddlGenre');
var ddlSubGenre =document.getElementById('ctl00_ContentPlaceHolder1_ddlSubGenre');
var ddlGender =document.getElementById('ctl00_ContentPlaceHolder1_ddlGender');
var ddlCountry=document.getElementById('ctl00_ContentPlaceHolder1_ddlCountry');
var ddlState =document.getElementById('ctl00_ContentPlaceHolder1_ddlState');
var ddlProfileStatus =document.getElementById('ctl00_ContentPlaceHolder1_ddlProfileStatus');
var ddlNoofAbuse=document.getElementById('ctl00_ContentPlaceHolder1_ddlNoOfAbuses');
var txtNoofAbuse=document.getElementById('ctl00_ContentPlaceHolder1_txtNoOfAbuse');
var ddlRegistered=document.getElementById('ctl00_ContentPlaceHolder1_ddlRegistered');
var txtRegistered=document.getElementById('ctl00_ContentPlaceHolder1_intxtRegistered');
//alert(ddlSubGenre.value);
if
(
txtUserName.value ==''
&& txtEmail.value==''
&& ddlGenre.value==''
&& ddlSubGenre.value==''
&& ddlGender.value ==''
&& ddlCountry.value==''
&& ddlState.value ==''
&& ddlProfileStatus.value ==''
&& ddlNoofAbuse.value==''
&& ddlRegistered.value==''
)
{ // {alert('me')
document.getElementById('ctl00_ContentPlaceHolder1_lblErrorMessage').innerHTML="Please select at least on search criteria";
return false;
}
break;
}
case "gt":
case "greaterthan":
{
if(isNaN(objValue.value))
{
alert(objValue.value+": Should be a number ");
alert(objValue.name+": Should be a number ");
return false;
}//if
if(eval(objValue.value) <= eval(cmdvalue))
{
alert(objValue.name+"AAA ");
if(!strError || strError.length ==0)
{
strError = objValue.name + " : value should be greater than "+ cmdvalue;
}//if
objErrorLbl.innerHTML = strError;
return false;
}//if
break;
}//case greaterthan
case "regexp":
{
if(objValue.value.length > 0)
{
if(!objValue.value.match(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Invalid characters found ";
}//if
objErrorLbl.innerHTML = strError;
return false;
}//if
}
break;
}//case regexp
case "dontselect":
{
if(objValue.selectedIndex == null)
{
//alert("BUG: dontselect command for non-select Item");
return false;
}
if(objValue.value == eval(cmdvalue))
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Please Select one option ";
}//if
objErrorLbl.innerHTML = strError;
return false;
}
break;
}//case dontselect
case "listSelection":
{
if(objValue.selectedIndex <0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Please Select one option ";
}//if
objErrorLbl.innerHTML = strError;
return false;
}
break;
}//case dontselect
case "specialChar":
{
var charpos = objValue.value.search("[<>]");
if(objValue.value.length > 0 && charpos >= 0)
{
if(!strError || strError.length ==0)
{
strError = objValue.name+": Invalid characters found ";
}
objErrorLbl.innerHTML = strError;
return false;
}
break;
}
case "dateDiff":
{
var exp=document.getElementById('ctl00_ContentPlaceHolder1_txtExpDate');
if(exp.value.length!=0 && objValue.value.length!=0)
{
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})\s*$/;
var blnIsValid=false;
var matchArray = objValue.value.match(datePat);
if (matchArray == null)
{ objErrorLbl.innerHTML = strError;
return false;
}
day1 = matchArray[1]; // parse date into variables
month1 = matchArray[3];
year1 = matchArray[4];
var matchArray = exp.value.match(datePat);
day2 = matchArray[1]; // parse date into variables
month2 = matchArray[3];
year2 = matchArray[4];
if(year1>year2)
{
blnIsValid=false;
}
else if(year1<year2)
{
blnIsValid=true;
}
else if(year1==year2)
{
if(month1>month2)
{
blnIsValid=false;
}
else if(month1<month2)
{
blnIsValid=true;
}
else if(month1==month2)
{
if(day1>day2)
{
blnIsValid=false;
}
else if(day1<day2)
{
blnIsValid=true;
}
else if(day1==day2)
{
blnIsValid=true;
}
}
}
if(!blnIsValid)
{
objErrorLbl.innerHTML = strError;
return false;
}
}
break;
}
}
return true;
}
// Trim leading and trailing spaces
function trim(lstr)
{
return ltrim(rtrim(stripLineFeed(lstr)));
}
function stripLineFeed(strText)
{
var strReturnText = strText;
var flgContinue = true;
// Only check if the string passed in has a length greater than zero
if (strReturnText.length > 0)
{
// Loop as long as the last character is either a line feed or a carriage return
while (flgContinue == true)
{
// If the last character is either a backspace or a line feed, strip it off
if (strReturnText.charAt(strReturnText.length - 1) == '\n' || strReturnText.charAt(strReturnText.length - 1) == '\r')
{
strReturnText = strReturnText.substr(0, strReturnText.length - 1);
}
else
{
// If the last character is not a carriage return or line feed, stop looping
flgContinue = false;
}
}
}
return strReturnText;
}
// This function trims all spaces from the left-hand side of a string.
function ltrim(lstr)
{
if (lstr != "")
{
var strlen, cptr, lpflag, chk;
strlen = lstr.length;
cptr = 0;
lpflag = true;
do
{
chk = lstr.charAt(cptr);
if (chk != " ")
{
lpflag = false;
}
else
{
if (cptr == strlen)
{
lpflag = false;
}
else
{
cptr++;
}
}
}
while (lpflag == true)
if (cptr > 0)
{
lstr = lstr.substring(cptr,strlen);
}
}
return lstr;
}
// This function trims all spaces from the right-hand side of a string.
function rtrim(lstr)
{
if (lstr != "")
{
var strlen, cptr, lpflag, chk;
strlen = lstr.length;
cptr = strlen;
lpflag = true;
do
{
chk=lstr.charAt(cptr-1);
if (chk != " ")
{
lpflag = false;
}
else
{
if (cptr == 0)
{
lpflag = false;
}
else
{
cptr--;
}
}
}
while (lpflag == true)
if (cptr < strlen)
{
lstr = lstr.substring(0, cptr);
}
}
return lstr;
}
function chkMinLen(objValue,minLen)
{
if(eval(objValue.value.length)>0)
{
//alert(objValue.value)
//alert(minLen)
if(eval(objValue.value.length) < eval(minLen))
{
// alert("Please enter a minimum of "+minLen + " characters.\n[Current length = " + objValue.value.length + " ]");
objValue.focus();
return false;
}//if
}
return true;
}
/*function checkCheckBox(f)
{
if (f.checkBox2.checked == false )
{
alert('Please check the box I Agree to abide by Rules and Regulations.');
return false;
}else
return true;
}
*/
/*function validateConfirm(vfld,ifld) // checkbox to be validated
// id of element to receive info/error msg
{
var stat = commonCheck2(vfld, ifld);
if (stat != proceed) return stat;
if (vfld.checked) return true;
// if we get here then the validation has failed
var errorMsg = 'Please read the above message and confirm you agree to it';
msg (ifld, "error", errorMsg);
return false;
}*/
/*
Copyright 2003 JavaScript-coder.com. All rights reserved.
*/
function OpenCalendar(strFormControlName)
{
var strControlName;
strControlName = "../Common/CalDate.aspx?controlName=" + strFormControlName;
var calendar_window=window.open(strControlName,'calendar_window','width=190px,height=140px,top=360px,left=180px,status=no');
calendar_window.focus();
}
function OpenCalendar1(strFormControlName,strFormControlName1, strFormControlName2)
{
var strControlName;
//alert(strFormControlName2);
//alert('fgdfg');
strControlName =
'../Common/CalDate.aspx?controlName=' + strFormControlName + '&controlName1=' + strFormControlName1 + '&controlName2=' + strFormControlName2 ;
var calendar_window=window.open(strControlName,'calendar_window', 'width=190px,height=140px,top=360px,left=180px,status=no');
calendar_window.focus();
}
function OpenCalendarIP(strFormControlName,strFormControlName1, strFormControlName2,strFormControlName3)
{
var strControlName;
//alert(strFormControlName2);
//alert('fgdfg');
strControlName =
'../Common/CalDate.aspx?controlName=' + strFormControlName + '&controlName1=' + strFormControlName1 + '&controlName2=' + strFormControlName2 + '&controlName3=Manage';
var calendar_window=window.open(strControlName,'calendar_window', 'width=190px,height=140px,top=360px,left=180px,status=no');
calendar_window.focus();
}
function Session_ExpMsg()
{
alert('Your session had expired. Please login again.')
}
function check()
{
if (confirm("Do you want to Delete"))
{
return true;
}
else
{
return false;
}
}
function confirmDelete ()
{
var frm=document.forms[0];
// loop through all elements
for (i=0; i<frm.length; i++)
{
// Look for our checkboxes only
if (frm.elements[i].name.indexOf("chkSelect") !=-1)
{
// If any are checked then confirm alert, otherwise nothing happens
if(frm.elements[i].checked)
{
return confirm ('Are you sure you want to delete your selection(s)?')
}
else
{
alert('Please select at least one checkbox');
return false;
}
}
}
}
function OpenNewCalendar(strFormControlName,strEndDate,BanDuration)
{
var strControlName;
strControlName = "../CalDate.aspx?controlName=" + strFormControlName+"&endDate="+strEndDate+"&banDuration="+BanDuration;
var calendar_window=window.open(strControlName,'calendar_window','width=190px,height=140px,top=360px,left=180px,status=no,menubar=1');
calendar_window.focus();
}