function makeArray(n) { for (var i = 1; i <= n; i++) { this[i] = 0 } return this } var daysInMonth = makeArray(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; var defaultEmptyOK = false // Check whether string s is empty. function isEmpty(s) { return ((s == null) || (s.length == 0)) } // isInteger (STRING s [, BOOLEAN emptyOK]) // // Returns true if all characters in string s are numbers. // // Accepts non-signed integers only. Does not accept floating // point, exponential notation, etc. function isInteger (s) { var i; if (isEmpty(s)) if (isInteger.arguments.length == 1) return defaultEmptyOK; else return (isInteger.arguments[1] == true); return s } // isNonnegativeInteger (STRING s [, BOOLEAN emptyOK]) // // Returns true if string s is an integer >= 0. // function isNonnegativeInteger (s) { var secondArg = defaultEmptyOK; if (isNonnegativeInteger.arguments.length > 1) secondArg = isNonnegativeInteger.arguments[1]; return (isSignedInteger(s, secondArg) && ( (isEmpty(s) && secondArg) || (parseInt (s) >= 0) ) ); } // isSignedInteger (STRING s [, BOOLEAN emptyOK]) // // Returns true if all characters are numbers; // first character is allowed to be + or - as well. // function isSignedInteger (s) { if (isEmpty(s)) if (isSignedInteger.arguments.length == 1) return defaultEmptyOK; else return (isSignedInteger.arguments[1] == true); else { return s } } // isYear (STRING s [, BOOLEAN emptyOK]) // // isYear returns true if string s is a valid // Year number. Must be 2 or 4 digits only. // // For Year 2000 compliance, you are advised // to use 4-digit year numbers everywhere. // // And yes, this function is not Year 10000 compliant, but // because I am giving you 8003 years of advance notice, // I don't feel very guilty about this ... // // For B.C. compliance, write your own function. ;-> // function isYear (s) { if (isEmpty(s)) if (isYear.arguments.length == 1) return defaultEmptyOK; else return (isYear.arguments[1] == true); if (!isNonnegativeInteger(s)) return false; return ((s.length == 2) || (s.length == 4)); } // isIntegerInRange (STRING s, INTEGER a, INTEGER b [, BOOLEAN emptyOK]) // // isIntegerInRange returns true if string s is an integer // within the range of integer arguments a and b, inclusive. // function isIntegerInRange (s, a, b) { if (isEmpty(s)) if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK; else return (isIntegerInRange.arguments[1] == true); // Catch non-integer strings to avoid creating a NaN below, // which isn't available on JavaScript 1.0 for Windows. if (!isInteger(s, false)) return false; // Now, explicitly change the type to integer via parseInt // so that the comparison code below will work both on // JavaScript 1.2 (which typechecks in equality comparisons) // and JavaScript 1.1 and before (which doesn't). var num = parseInt (s); return ((num >= a) && (num <= b)); } // isMonth (STRING s [, BOOLEAN emptyOK]) // // isMonth returns true if string s is a valid // month number between 1 and 12. function isMonth (s) { if (isEmpty(s)) if (isMonth.arguments.length == 1) return defaultEmptyOK; else return (isMonth.arguments[1] == true); return isIntegerInRange (s, 1, 12); } // isDay (STRING s [, BOOLEAN emptyOK]) // // isDay returns true if string s is a valid // day number between 1 and 31. function isDay (s) { if (isEmpty(s)) if (isDay.arguments.length == 1) return defaultEmptyOK; else return (isDay.arguments[1] == true); return isIntegerInRange (s, 1, 31); } // 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 ); } // 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) { // catch invalid years (not 2- or 4-digit) and invalid months and days. if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false; // Explicitly change type to integer to make code work in both // JavaScript 1.1 and JavaScript 1.2. var intYear = parseInt(year); var intMonth = parseInt(month); var intDay = parseInt(day); // catch invalid days, except for February if (intDay > daysInMonth[intMonth]) return false; if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false; return true; } function check_text_date (xdate) { x_date = xdate.value; var pos1 = x_date.indexOf("/", 0); var pos2 = x_date.indexOf("/", pos1+1); // alert(x_date); x_month = x_date.substring(0, pos1); // alert(x_month); x_days = x_date.substring(pos1 + 1,pos2); // alert(x_days); x_year = x_date.substring(pos2+1); // alert(x_year); // alert(x_year + "/"+ x_month +"/"+ x_days); if(!isDate (x_year, x_month, x_days)) { return false; } return true; } function checkNumber(input) { // this function checks for valid numbers returns true for valid number var str = input.value; for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i + 1) if ((ch < "0" || "9" < ch)) { return false; } } return true; } function checkDecimal(input) {// this function checks for valid numbers returns true for valid number var isNum = 0; var str = input.value; var index1 = index2 = 0 var min_error = -1; for (j = 0; j < str.length; j++) { if ((str.substring(j,j+1) != "0") && (str.substring(j,j+1) != "1") && (str.substring(j,j+1) != "2") && (str.substring(j,j+1) != "3") && (str.substring(j,j+1) != "4") && (str.substring(j,j+1) != "5") && (str.substring(j,j+1) != "6") && (str.substring(j,j+1) != "7") && (str.substring(j,j+1) != "8") && (str.substring(j,j+1) != "9") && (str.substring(j,j+1) != "-") && (str.substring(j,j+1) != ".")) { isNum = -1; break; } } if(isNum == 0) { index1 = str.indexOf(".", 0); index1 = str.indexOf(".", index1+1); index2 = str.indexOf("-", 0); if(index2 > -1) { // alert(str.length); if(str.substring(0,1) != "-") { min_error = 0; } if(str.length == 1) { min_error = 0; } } index2 = str.indexOf("-", index2+1); // alert(min_error); } if (isNum == 0 && index2 == -1 && index1 == -1 && min_error == -1) return true; else return false; } // this function checks for null entry , returns true if null function checkNull(input) { var str = input.value; if((str == null) || (str == "") || (str == " ") || (str.length == 0) || (str == " ") || (str == " ") || (str == " ")) { return true; } return false; } function checkLen(input) { var str = input.len; alert(str); return false; if((str == null) || (str == "") || (str == " ") || (str.length == 0) || (str == " ") || (str == " ") || (str == " ")) { return true; } return false; } function checkList(input) { var str = input; alert(str); if((str == null) || (str == "") || (str == " ")) { return true; } return false; } function emailcheck(efield) {// email check function takes input a string and returns true if the string is a //valid email id. var e_field = efield.value; var domain = "", lastdot = 0, len = 0, number_at = 0; var find_at1 = -1, find_at2 = -1; find_at1 = e_field.indexOf("@",0); if(find_at1 <= 0) { return false; } else { find_at2 = e_field.indexOf("@",find_at1+1); if(find_at2 != -1) { return false; } } len = e_field.length; lastdot = e_field.lastIndexOf("."); if(lastdot < find_at1) return false; if(e_field.lastIndexOf(".") == len-1) return false; return true; } function grle(v_field) { var len,lastIndex; var l_index = -1; // check for the '<' operator l_index = v_field.indexOf("<", 0); if(l_index >=0){ return false; } // check for the '>' operator l_index = v_field.indexOf(">",0); if(l_index >=0){ return false; } return true; } function checkurl(v_field) { var l_index = -1; var l_index2 = -1; // check for the '<' operator l_index = v_field.indexOf("http://", 0); l_index2 = v_field.indexOf("http://", 6); if(l_index ==0 && l_index2 == -1){ return true; } return false; } function compare_string(field1,field2) { var error = 0; // implies no error string is equal var str = field1.value; var str2 = field2.value; if (str.length == str2.length) { error = 0; for (var i = 0; i < str.length; i++) { if (str.substring(i, i + 1) != str2.substring(i, i + 1)) { error = -1; break; } } } else { error = -1; } if (error == -1) { return false; } else { return true; } } function CheckForm() { if (checkNull(document.LoginForm.userName)) { alert("Username Cannot Be Null"); document.LoginForm.userName.focus(); return false; } if (checkNull(document.LoginForm.Password)) { alert("Password Cannot Be Null"); document.LoginForm.Password.focus(); return false; } return true; } Be a part of the solution
SolveIT.com Home  
 July 04 , 2009
   
Home |About Us | Policies | Questions/Feedback | Login    
Member Login
User Name
Password
Register now
Forgot your password?
Industry Solutions
Hardware
Software
Services
Companies
System Integrators
Distributors
Resources
Tell a friend
Feedback
User Settings

Welcome to SolveIT.com

Browse interactive 3D solution architectures

Solutions for General Application

Education Solutions

Field Sales and Field Service Solutions

Food Service Solutions

Healthcare Solutions

Manufacturing Solutions

Public Safety Solutions

Retail Solutions

Small Office & Home Office Solutions

Transportation Solutions

Utilities Solutions

Warehousing Solutions

 © 2000, MindMatrix, Inc.
 Terms and Conditions
 Patent Pending
Home | About Us | Policies | Questions/Feedback | Login