﻿
var objUsername=".0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";var objNumber=".0123456789";var objMoney=".,0123456789";var objWholeNumber="0123456789";var objPagingNumber="123456789";var objTelephone="-()0123456789";var objName=" .0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'-";var objAlpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";var objCountry="ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz. ";var objemail=".@-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";var objUsername1=".0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz ";var objZipCode=" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";var objFullName="ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz ";function isRule(oComp,sRule,nLength,fdecimal)
{if(fdecimal==""||typeof(fdecimal)=="undefined")
{fdecimal=false;}
if(typeof(oComp)=='undefined'||oComp==null||oComp=='')
{alert('Error: Input object not specified.');return false;}
else if(typeof(sRule)=='undefined'&&typeof(nLength)=='undefined')
{alert('Error: No rule/maximum length for input object specified.');return false;}
var noErrorFlg=true;if(typeof(sRule)!='undefined'&&sRule!=null)
{var temp;sRule=sRule+"";var discardChars=false;if(sRule.length>0&&sRule.charAt(0)=="~")
{sRule=sRule.substring(1);discardChars=true;}
if(typeof(oComp)=="undefined"||typeof(sRule)=="undefined")
return false;for(var i=0;i<oComp.value.length;i++)
{temp=oComp.value.charAt(i);if((!discardChars&&sRule.indexOf(temp)==-1)||(discardChars&&sRule.indexOf(temp)>=0))
{alert("Invalid Character!");oComp.value=oComp.value.substring(0,i);noErrorFlg=false;break;}}}
if(nLength)
{if(fdecimal)
{nLength-=fdecimal;var dp=oComp.value.indexOf(".");var p1;var p2="";;if(dp>=0)
{p1=oComp.value.substring(0,dp);p2=oComp.value.substring(dp+1);}
else
{p1=oComp.value;}
if(p1.length>nLength)
{oComp.value=oComp.value.substring(0,nLength);return noErrorFlg;}
for(var i=0;i<p2.length;i++)
{var ch=p2.charAt(i);if(ch<'0'||ch>'9')
{oComp.value=p1+"."+p2.substring(0,i);return noErrorFlg;}}
if(p2.length>fdecimal)
{oComp.value=p1+"."+p2.substring(0,fdecimal);}}
else if(oComp.value.length>nLength)
{oComp.value=oComp.value.substring(0,nLength);}}
return noErrorFlg;}
function trimText(strComp)
{var ltrim=/^\s+/
var rtrim=/\s+$/
strComp=strComp.replace(ltrim,'');strComp=strComp.replace(rtrim,'');return strComp;}
function isValidEMail(str)
{var emailexp=/^[a-z][a-z_0-9\-\.]+@[a-z_0-9\-\.]+\.[a-z]{2,4}$/i
if(!emailexp.test(str)||str.indexOf("..")>=0)
{return false;}
return true;}
function trim(s)
{while(s.substring(0,1)==' ')
{s=s.substring(1,s.length);}
while(s.substring(s.length-1,s.length)==' ')
{s=s.substring(0,s.length-1);}
return s;}
function isRuleBlank(oComp,sRule,nLength,fdecimal)
{if(fdecimal==""||typeof(fdecimal)=="undefined")
{fdecimal=false;}
if(typeof(oComp)=='undefined'||oComp==null||oComp=='')
{alert('Error: Input object not specified.');return false;}
else if(typeof(sRule)=='undefined'&&typeof(nLength)=='undefined')
{alert('Error: No rule/maximum length for input object specified.');return false;}
var noErrorFlg=true;if(typeof(sRule)!='undefined'&&sRule!=null)
{var temp;sRule=sRule+"";var discardChars=false;if(sRule.length>0&&sRule.charAt(0)=="~")
{sRule=sRule.substring(1);discardChars=true;}
if(typeof(oComp)=="undefined"||typeof(sRule)=="undefined")
return false;for(var i=0;i<oComp.value.length;i++)
{temp=oComp.value.charAt(i);if((!discardChars&&sRule.indexOf(temp)==-1)||(discardChars&&sRule.indexOf(temp)>=0))
{oComp.value=oComp.value.substring(0,i);noErrorFlg=false;break;}}}
if(nLength)
{if(fdecimal)
{nLength-=fdecimal;var dp=oComp.value.indexOf(".");var p1;var p2="";;if(dp>=0)
{p1=oComp.value.substring(0,dp);p2=oComp.value.substring(dp+1);}
else
{p1=oComp.value;}
if(p1.length>nLength)
{oComp.value=oComp.value.substring(0,nLength);return noErrorFlg;}
for(var i=0;i<p2.length;i++)
{var ch=p2.charAt(i);if(ch<'0'||ch>'9')
{oComp.value=p1+"."+p2.substring(0,i);return noErrorFlg;}}
if(p2.length>fdecimal)
{oComp.value=p1+"."+p2.substring(0,fdecimal);}}
else if(oComp.value.length>nLength)
{oComp.value=oComp.value.substring(0,nLength);}}
return noErrorFlg;}
function numbersonly(myfield,e,dec)
{var key;var keychar;if(window.event)
key=window.event.keyCode;else if(e)
key=e.which;else
return true;keychar=String.fromCharCode(key);if((key==null)||(key==0)||(key==8)||(key==9)||(key==13)||(key==27))
return true;else if((("0123456789").indexOf(keychar)>-1))
return true;else if(dec&&(keychar=="."))
{myfield.form.elements[dec].focus();return false;}
else
return false;}
function IsValidDocFile(cntrlValue){var strFileExt=cntrlValue.substring(cntrlValue.lastIndexOf('.')+1,cntrlValue.length)
if(strFileExt.toLowerCase()=='txt'||strFileExt.toLowerCase()=='doc'||strFileExt.toLowerCase()=='docx')
return true;else
return false;}
function isValidEmail(){var str=document.getElementById("tbxEmailID").value;if(str=='Subscribe to our newsletter'||str==''){alert('Please enter your email address');$("#tbxEmailID").val('');$("#tbxEmailID").focus();return false;}
else{if(isValidEMail(str)>0){return true;}
else{alert('Invalid email address');$("#tbxEmailID").focus();return false;}}}
