//Purpose : Validating for numeric entry in a text box //Author : Vivek Rathore //Date : October,17 2007 //Syntax : onBlur = "return validateNum(fname,integerChk,positiveChk,zeroChk, len, flag,fnameLabel);" //integerChk : true if checking for integer //positiveChk : true if checking for positive number //zeroChk : true if checking for Zero //len : Checking minimum length required //flag : true if u want to check for minimum //fnameLabel : Label for Alert function validateNum(fname,integerChk,positiveChk,zeroChk, len, flag,fnameLabel) { if (fname.value != "") { var eleArr = "" eleArr= fname.value var nullFound=true for(var s=0;s f_size) && cancelclick==0 && backclick==0) { field.value = ""; alert("Invalid length, minimum length should be "+f_size); field.trigger('focus'); return false; } cancelclick=0; backclick=0; return true; } 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; i0&&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= 1 character before @, so we // start looking at character position 1 // (i.e. second character) var i = 1; var sLength = s.length; // look for @ while ((i < sLength) && (s.charAt(i) != "@")) { i++ } if ((i >= sLength) || (s.charAt(i) != "@")) return false; else i += 2; // look for . while ((i < sLength) && (s.charAt(i) != ".")) { i++ } // there must be at least one character after the . if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false; else return true; } function isFutureDate(m, d, y) { var now = getCurrentDate(); if (m.length == 1) { m = '0'+m; } if (d.length == 1) { d = '0'+d; } if (y+m+d < now) { return false; } else { return true; } } function isFutureYear(y) { var thisYear = getCurrentYear(); if (y < thisYear) { return false; } else { return true; } } function getCurrentDate() { //returns YYYYMMDD format var dt = new Date(); var y = dt.getYear(); if (y < 1900) y += 1900; var m = '0'+(dt.getMonth()+1);//zero-based m = m.substr(m.length - 2); var d = '0'+dt.getDate(); d = d.substr(d.length - 2); return (y+m+d); } function getCurrentYear() { var dt = new Date(); var y = dt.getYear(); if (y < 1900) y+= 1900; return y; } // isDate (STRING year, STRING month, STRING day) // // isDate returns true if string arguments year, month, and day // form a valid date. // function isDate (year, month, day) { var daysInMonth = new Array(12); daysInMonth[1] = 31; daysInMonth[2] = 29; // must programmatically check this daysInMonth[3] = 31; daysInMonth[4] = 30; daysInMonth[5] = 31; daysInMonth[6] = 30; daysInMonth[7] = 31; daysInMonth[8] = 31; daysInMonth[9] = 30; daysInMonth[10] = 31; daysInMonth[11] = 30; daysInMonth[12] = 31; // Explicitly change type to integer to make code work in both // JavaScript 1.1 and JavaScript 1.2. var intYear = parseInt(year,10); var intMonth = parseInt(month,10); var intDay = parseInt(day,10); // catch invalid days, except for February if (intDay > daysInMonth[intMonth]) return false; if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false; return true; } // daysInFebruary (INTEGER year) // // Given integer argument year, // returns number of days in February of that year. function daysInFebruary (year) { // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return ( ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 ); } function startBeforeEnd(sm, sd, sy, em, ed, ey) { if (sy+sm+sd > ey+em+ed) { return false; } else { return true; } } function selectItem(comp, value) { if (value != '') { for (var i=0; i -1); strVal = strVal.substring (0, i + 2); return strVal; } function isValidDate(str) { //expect MM/DD/YYYY var dt = new Date(Date.parse(str)); if (isNaN(dt)) return false; var y = dt.getYear(); if (y < 1900) y += 1900; var m = '0'+(dt.getMonth()+1);//zero-based m = m.substr(m.length - 2); var d = '0'+dt.getDate(); d = d.substr(d.length - 2); return (m+"/"+d+"/"+y == str); } function isValidText(val) { if (val.length > 0) { if (isAlpha(val.charCodeAt(0))) { //first char must be alphanum return true; } } return false; } function isAlpha(c) { return ((c>64 && c<91) || (c>96 && c<123)); } function isAlphaNumeric(c) { return ((c>47 && c<58) || (c>64 && c<91) || (c>96 && c<123)); } //Character Validation function validateInputText(fieldElement) { var myMatch = /[^a-zA-Z-' ]/ if (fieldElement.value.search(myMatch)>-1){ //if match failed alert("We apologize for the inconvenience, but we cannot create your account using the name information provided. Please limit your entry to the following characters: ‘a’ through ‘z’, ‘A’ through ‘Z’, - (dash), ‘ ‘ (space), and ' (apostrophe)."); return false; }else{return true} } function validateInputAsciiText(fieldElement) { var myMatch = /[^\041-\176]/; if (fieldElement.value.search(myMatch)>-1){ //if match failed fieldElement.value = ''; alert("Passwords are limited to ASCII letters, ASCII digits, and printable ASCII special characters."); return false; }else{return true} } function displayHelp(eid, msg) { var element = document.getElementById(eid); x = element.offsetLeft; y = element.offsetTop w = element.width; document.getElementById('ehelp').style.left=x+w+5; document.getElementById('ehelp').style.top=y; document.getElementById('ehelp').style.display="block"; document.getElementById('ehelp').innerHTML= msg; document.getElementById('ehelp').style.display="block"; document.getElementById('ehelp').style.width="350px"; document.getElementById('ehelp').style.background="#e3f1ff"; document.getElementById('ehelp').style.border="1px solid #0167cc"; } function hideHelp() { document.getElementById('ehelp').style.display="none"; } function ticketSubmit(userName,userEmail,userFirstName,userLastName,url){ var x = 0, y = 0; if (document.all) { x = window.screenTop; y = window.screenLeft; } else if (document.layers) { x = window.screenX; y = window.screenY; } var availHeight = screen.availHeight; var availWidth = screen.availWidth; var name = "RightNowSubmitWindow"; var features = 'resizable=yes,location=1,toolbars=1,scrollbars=1,menubar=1,top=0,left=0,width='+ availWidth +',height='+availHeight+',screenX='+x+',screenY='+y; window.open(url,name, features); } function viewTicket(userName,userEmail,userFirstName,userLastName,url){ var x = 0, y = 0; if (document.all) { x = window.screenTop; y = window.screenLeft; } else if (document.layers) { x = window.screenX; y = window.screenY; } var availHeight = screen.availHeight; var availWidth = screen.availWidth; var name = "RightNowViewWindow"; var features = 'resizable=yes,location=1,toolbars=1,scrollbars=1,menubar=1,top=0,left=0,width='+ availWidth +',height='+availHeight+',screenX='+x+',screenY='+y; window.open(url,name, features); }