function testConditions(sTestVal,sCondition__s,sRetMsg__) { var aConditions__=sCondition__s.split(","); for (var i=0;i-1) return sRetMsg__; if (isNaN(parseInt(sText__))) return sRetMsg__; if (sCondition__s) return testConditions(sText__,sCondition__s,sRetMsg__); return ""; } function isDateStr__(sText__,sCondition__s) { var sMonths__="jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec,"; var sRetMsg__="Not a valid date (eg: 1 Jan 2007)"; //return (""); if (sText__=="") return ""; var aDate__=sText__.split(" "); if (aDate__.length<3) return sRetMsg__; var sDay__=aDate__[0]; var sMonth__=aDate__[1].toLowerCase(); var sYear__=aDate__[2]; if (isInt__(sDay__)!="") return sRetMsg__; if (sMonths__.indexOf(sMonth__ + ",")<0) return sRetMsg__; if (isInt__(sYear__)!="" || sYear__.length!=4) return sRetMsg__; sMonth__=sMonths__.indexOf(sMonth__ + ",")/4; //0-11 var dtDate__ = new Date(sYear__, sMonth__, sDay__); return (sMonth__==dtDate__.getMonth()) ? "" : sRetMsg__; } function isFloat__(sText__,sCondition__s) { var sRetMsg__="Not a valid number"; if (sText__=="") return ""; if (isNaN(parseFloat(sText__))) return sRetMsg__; if (sCondition__s) return testConditions(sText__,sCondition__s,sRetMsg__); return ""; } function isLength__(sText__,sCondition__s) { if (sText__=="") return ""; if (sCondition__s.indexOf("<")>-1) { var sRetMsg__="Exceeded maximum of " + sCondition__s.substr(2) + " characters"; } else { var sRetMsg__="Must be at least " + sCondition__s.substr(2) + " characters"; } if (sCondition__s) return testConditions(sText__.length,sCondition__s,sRetMsg__); return ""; } function isNotEmpty__(sText__,sCondition__s) { var sRetMsg__="Value is required"; return testConditions(sText__.length,">0",sRetMsg__); return ""; } function isEmail__(sEmail,sCondition__s) { var sRetMsg__="Not a valid email address"; if (sEmail.length==0) return ""; var Atom__="[^\\(\\)<>@,;:\\\\\"\\.\\[\\]\\s]+"; var LocalPart__="(" + Atom__ + "\\.)*" + Atom__; var Domain__="(" + Atom__ + "\\.)+" + "\\w{2,4}"; var AddrSpec__="^" + LocalPart__ + "@" + Domain__ + "$"; var EmailPat__=new RegExp(AddrSpec__); if (!EmailPat__.test(sEmail)) return sRetMsg__; if (sCondition__s) return testConditions(sText__,sCondition__s,sRetMsg__); return ""; } function isImageFile__(sText__,sCondition__s) { if (sText__.length==0) return ""; var sRetMsg__="Not a valid image file - must be GIF, JPG or PNG format"; sText__=sText__.toLowerCase(); var sExt__=sText__.substr(sText__.length-4); if (sExt__!=".gif" && sExt__!=".jpg" && sExt__!=".png") return sRetMsg__; return ""; } function isFlashFile__(sText__,sCondition__s) { if (sText__.length==0) return ""; var sRetMsg__="Not a valid flash (swf) file"; sText__=sText__.toLowerCase(); var sExt__=sText__.substr(sText__.length-4); if (sExt__!=".swf" && sExt__!=".flv") return sRetMsg__; return ""; } function isDocumentFile__(sText__,sCondition__s) { if (sText__.length==0) return ""; var sRetMsg__="Not a valid document file - must be DOC or PDF format"; sText__=sText__.toLowerCase(); var sExt__=sText__.substr(sText__.length-4); if (sExt__!=".doc" && sExt__!=".pdf") return sRetMsg__; return ""; } function isURL__(sText__,sCondition__s) { if (sText__.length==0) return ""; var sRetMsg__="Not a valid URL - must begin with http://"; sText__=sText__.toLowerCase(); if (sText__.substr(0,7)!="http://" && sText__.substr(0,8)!="https://") return sRetMsg__; return ""; } function isInternalLink__(sText__,sCondition__s) {// var sRetMsg__="Not a valid internal link\r Internal links must start with a forward-slash(/) and end in .asp\r Internal links should contain no spaces or symbols other than: \r letters a-z\r numbers\r dashes (can be used instead of spaces)\r forward slashes (/)"; if (sText__=="") return ""; var re = /^\/[a-zA-Z0-9\-\.\/]+\.(asp|ASP)$/ ; if(!re.test(sText__)) return sRetMsg__; if(sText__.indexOf("//")>-1) return sRetMsg__; var sPath__=sText__.substr(0,sText__.substr(1).indexOf("/")+2).toLowerCase(); try { if(sSysFolders__.indexOf("|" + sPath__ + "|")>-1) return "Internal link " + sText__ + " is within a system folder - please specify a different internal link for this page"; } catch(e){} //if (sCondition__s) return testConditions(sText__,sCondition__s,sRetMsg__); return ""; } function isRadioButtonChecked(oRadioButton) { var sRetMsg__="Value is required"; for (i=0;i-1) return sRetMsg__; if (sCondition__s) return testConditions(sText__,sCondition__s,sRetMsg__); return ""; } //Note - this function should not be duplicated in the jscript version function Iif__(expre,truepart,falsepart) { //alert(expre); if (eval(expre)) return truepart; else return falsepart; } function isDateTomorrow__(sText__) { var sRetMsg__ = ""; try { if( sText__ == "" ) { return ""; } var dtText__ = Date.parse(sText__); if( isNaN(dtText__) ) { return ""; } var dtToday__ = new Date(); if( !(dtText__ > dtToday__) ) { sRetMsg__ = "Date must be greater than today" ; } } catch(e) {} return( sRetMsg__ ); }