// ############################################################ // # All design & code is the sole property # // # of Robert A. Ross (196427413) # // # Contact: robross@comcast.net # // ############################################################ // # Leave this header in this file ! # // ############################################################ // This file contains the data validation JavaScript functions // It is included in the HTML pages with forms that need these // data validation routines. function toggleT(_w,_h) { //Show or hide dhtml sections // _w : which ID // _h : (h)ide or (s)how if (document.all) { // is IE var allforms = document.forms; for (x=0; x 126 && ascii != 127)) { event.keyCode = 0; return false; } } if (document.layers) { var ascii = source.which; if ((ascii < 20 && ascii != 8) || (ascii > 126 && ascii != 127)) { source.which = 0; return false; } } if (source.value.length == length) { target.focus(); target.select(); return true; } else { return false; } } function myExitRoutine () { alert ( "GoodBye Cruel World! You are leaving my Web Page." ) } function compare(field1,field2,message) { if (field1.value != field2.value){ alert(message); field1.value = ""; field2.value = ""; field1.focus(); return false; } else { return true; } } function goBack() { window.location = document.referrer; } function Datecompare(S1, S2) { X = replaceAll (S1.value, "-", ""); Y = replaceAll (S2.value, "-", ""); if (X>Y && X!="" && Y!=""){ alert("Your date values do not make chronological sense.\nPlease fix and try again."); return false; } else { return true; } } function limitOptions(item,max) { var selectCount = 0; if(item.type=="select") { var totalOptions = item.length; for (var i = 0; i < totalOptions; i++) { if (item.options[i].selected) { selectCount = selectCount +1; if (selectCount > max) { alert("Your package only allows for " + max + " selection(s)."); item.options[i].selected = false; } } } } if(item.type=="checkbox") { var formobj = item.form; for (var i=0; i < formobj.length; i++) { var elementobj = formobj.elements[i]; if(elementobj.name==item.name && elementobj.checked) { selectCount = selectCount + 1; if(selectCount > max) { alert("Your package only allows for " + max + " selection(s)."); elementobj.checked = false; } } } } } function popUp(mypage,myname,w,h,pos,menu){ if(pos=="random"){ LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100; TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100; } if(pos=="center"){ LeftPosition=(screen.width)?(screen.width-w)/2:100; TopPosition=(screen.height)?(screen.height-h)/2:100; } else if((pos!="center" && pos!="random") || pos==null){ LeftPosition=0; TopPosition=20; } if(menu==""){ menu="no"; } settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar='+menu+',toolbar=no,resizable=no'; win=window.open(mypage,myname,settings); win.focus(); //return win; } function popUpClose(currentObject, myWindow) { alert( currentObject.toString() ); } function validCCN(inCCN) { if (inCCN == "") { return true } if (inCCN.length <=14) { return false } if (inCCN.length >=17) { return false } if (isNum(inCCN)) { return true } return false } function validEmail(email,blankallowed) { invalidChars = " /:,;" email = trim(email.value); if (email=="" && blankallowed=="no") { alert("Your email address appears to be blank.\nPlease re-enter your email address."); return false } for (i=0; i -1) { alert("Your email address appears to contain invalid characters.\nPlease re-enter your email address."); return false } } atPos = email.value.indexOf("@",1) if (atPos == -1 && blankallowed=="no") { alert("Your email address does not appear to be valid.\nPlease re-enter your email address."); return false } if (email.value.indexOf("@",atPos+1) > -1) { alert("Your email address does not appear to be valid.\nPlease re-enter your email address."); return false } periodPos = email.value.indexOf(".",atPos) if (periodPos == -1 && blankallowed=="no") { alert("Your email address does not appear to be valid.\nPlease re-enter your email address."); return false } if (email.value.charAt(periodPos+1) == ".") { alert("Your email address does not appear to be valid.\nPlease re-enter your email address."); return false } if (periodPos+3 > email.length) { alert("Your email address does not appear to be valid.\nPlease re-enter your email address."); return false } return true } // Check to see if the string passed in is a valid time. // A valid time is defined as a string which is postfixed with either // "PM" or "AM". Next it checks to see if there is a colon in the // string. If there is, it makes sure that at least one digit preceeds // it and two proceed it. function IsTime(strTime) { var strTestTime = new String(strTime); strTestTime.toUpperCase(); var bolTime = false; if (strTestTime.indexOf("PM",1) != -1 || strTestTime.indexOf("AM",1)) bolTime = true; if (bolTime && strTestTime.indexOf(":",0) == 0) bolTime = false; var nColonPlace = strTestTime.indexOf(":",1); if (bolTime && ((parseInt(nColonPlace) + 5) < (strTestTime.length - 1) || (parseInt(nColonPlace) + 4) > (strTestTime.length - 1))) bolTime = false; return bolTime; } // This function can replace all instances of a string(fromStr) // with another string (toStr) wihin a given string(s) function replaceAll (s, fromStr, toStr) { var new_s = s; for (i = 0; i < 100 && new_s.indexOf (fromStr) != -1; i++) { new_s = new_s.replace (fromStr, toStr); } return new_s; } // Since we are using the single tick mark as the // string delimiter to construct our SQL queries, a string with // a tick mark in it will cause a SQL error. Therefore we replace // all "'" with "''", which eliminates the possibility of a SQL error. function sqlSafe (s) { var new_s = s; new_s = replaceAll (new_s, "'", "|"); new_s = replaceAll (new_s, "|", "''"); new_s = replaceAll (new_s, "\"", "|"); new_s = replaceAll (new_s, "|", "''"); return new_s; } function makeSafe (i) { i.value = sqlSafe (i.value); } // Check whether string s is empty. // Returns true if string s is empty or // whitespace characters only. function isEmpty(s) { return ((s == null) || (s.length == 0)) } function isWhitespace (s) { var i; // Is s empty? if (isEmpty(s)) return true; // Search through string's characters one by one // until we find a non-whitespace character. // When we do, return false; if we don't, return true. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (whitespace.indexOf(c) == -1) return false; } // All characters are whitespace. return true; } // Checks to see if a required field is blank. // This utilizes the isWhitespace and isEmpty functions // If it is, a warning message is displayed... function ForceEntry(objField, FieldName) { var strField = new String(objField.value); if (isWhitespace(strField)) { alert("You need to enter information for " + FieldName); objField.focus(); objField.select(); return false; } return true; } // Returns true if the string passed in is a valid number // (no alpha characters), else it displays an error message function ForceNumber(objField, FieldName) { var strField = new String(objField.value); if (isWhitespace(strField)) return true; var i = 0; for (i = 0; i < strField.length; i++) if (strField.charAt(i) < '0' || strField.charAt(i) > '9') { alert(FieldName + " must be a valid numeric entry. Please do not use commas or dollar signs or any non-numeric symbols."); objField.focus(); return false; } return true; } // Returns true if the string passed in is a valid money // (no alpha characters except a decimal place), // else it displays an error message function ForceMoney(objField, FieldName) { var strField = new String(objField.value); if (isWhitespace(strField)) return true; var i = 0; for (i = 0; i < strField.length; i++) if ((strField.charAt(i) < '0' || strField.charAt(i) > '9') && (strField.charAt(i) != '.')) { alert(FieldName + " must be a valid numeric entry. Please do not use commas or dollar signs or any non-numeric symbols."); objField.focus(); return false; } return true; } // Right trims a string... Useful for SQL datatypes of CHAR function RTrim(strTrim) { var str = new String(strTrim); var i = 0; var c = ""; var endpos = 0 for (i = str.length; i >= 0 && endpos == 0; i = i - 1) { c = str.charAt(i); if (whitespace.indexOf(c) == -1) endpos = i; } return str.substring(0,endpos+1); } // Removes leading and trailing spaces from the passed string. Also removes // consecutive spaces and replaces it with one space. If something besides // a string is passed in (null, custom object, etc.) then return the input. function trim(inputString) { if (typeof inputString != "string") { return inputString; } var retValue = inputString; var ch = retValue.substring(0, 1); while (ch == " ") { // Check for spaces at the beginning of the string retValue = retValue.substring(1, retValue.length); ch = retValue.substring(0, 1); } ch = retValue.substring(retValue.length-1, retValue.length); while (ch == " ") { // Check for spaces at the end of the string retValue = retValue.substring(0, retValue.length-1); ch = retValue.substring(retValue.length-1, retValue.length); } while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings } return retValue; // Return the trimmed string back to the user } // Ends the "trim" function // Returns true if the string is a valid date number. // A method is passed in (1 = month, 2 = day). If the string is // nonnumeric, false is passed back. If the day in the date string // is greater than 31, false is returned. If the month is greater // than 12, an error is returned. function isDateNumber(strNum,method) { var str = new String(strNum); var i = 0; if (isNaN(parseInt(str)) || parseInt(str) < 0) return false; if (method == 2) if (parseInt(str) > 31) return false; if (method == 1) if (parseInt(str) > 12) return false; for (i = 0; i < str.length; i++) if (str.charAt(i) < '0' || str.charAt(i) > '9') return false; return true; } // Displays an alert box with the passed in string... function PromptErrorMsg(Field,strError) { alert("You have entered an invalid date for " + strError + ". Please make sure your date format is in M/D/Y format."); Field.focus(); } // PURPOSE: Checks to see if the string is a valid date. A valid // date is defined as any of the following: // MM/DD/YY, MM/DD/YYYY, M/D/YY, M/D/YYYY, // MM-DD-YY, MM-DD-YYYY, M-D-YY, M-D-YYYY function ForceDate(strDate,strField) { var str = new String(strDate.value); if (isWhitespace(str)) { return true; // if the field is empty, just return true... } var i = 0, count = str.length, j = 0; while ((str.charAt(i) != "/" && str.charAt(i) != "-") && i < count) i++; if (i == count || i > 2) { PromptErrorMsg(strDate,strField); return false; } var addOne = false; if (i == 2) addOne = true; if (!isDateNumber(str.substring(0,i),1)) { PromptErrorMsg(strDate,strField); return false; } j = i+1; i = 0; while ((str.charAt(i+j) != "/" && str.charAt(j+i) != "-") && i+j < count) i++; if (i+j == count || i > 2) { PromptErrorMsg(strDate,strField); return false; } if (!isDateNumber(str.substring(j,i+j),2)) { PromptErrorMsg(strDate,strField); return false; } j = i+3; i = 0; if (addOne) j++; while (i+j < count) i++; if (i != 2 && i != 4) { PromptErrorMsg(strDate,strField); return false; } if (!isDateNumber(str.substring(j,i+j),3)) { PromptErrorMsg(strDate,strField); return false; } return true; } // This function determines if the string passed in is a valid // US zip code. It accepts either ##### or #####-####. If the // string is valid, it returns true, else false. function isZipcode(strZip) { var s = new String(strZip); if (s.length != 5 && s.length != 10) // inappropriate length return false; for (var i=0; i < s.length; i++) if ((s.charAt(i) < '0' || s.charAt(s) > '9') && s.charAt(i) != '-') return false; return true; } // This function ensures that a field is less than or equal to the // Length passed in. You must call this function with the element // name in your form (for example: "ForceLength(document.forms[0].txtElement)" // as opposed to "ForceLength(document.forms[0].txtElement.value)" // If the field's value is too large, an error message is displayed // and false is returned, else true is returned. function ForceLength(objField, nLength, strWarning) { var strField = new String(objField.value); if (strField.length > nLength) { alert(strWarning); return false; } else return true; } //Get cookie routine function getCookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) // if cookie exists if (offset != -1) { offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset); // set index of end of cookie value if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } // Form Guard // Copyright Xin Yang 2003, 2004 // Web Site: www.yxScripts.com // EMail: m_yangxin@hotmail.com // Last Updated: Sep-01-2004 // This script is free as long as the copyright notice remains intact. // to consolidate all error messages var totalAlert=""; // form submit counter var submitCounter=0; // regular expressions used by checking functions var reNonBlank=/[\S]/; var reHexColor=/^#[0-9a-fA-F]{6}$/; var reInt=/^\d+$/; var reSignedInt=/^(\+|-)?\d+$/; var reFloat=/^\d+(\.\d+)?$/; var reSignedFloat=/^(\+|-)?\d+(\.\d+)?$/; var reChar=/^[\w\-]+$/; var reEMail=/^\w[\w\-\.]+\@\w[\w\-]+(\.\w[\w\-]+)+$/; var reIP=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; var rePostalCA=/^(\w\d){3}$/; var reURL=/^http(s)?\:\/\/\w[\w\-]+(\.\w[\w\-]+)+([\/\%\?\&\+\#\.\w\-]+)*$/; function rpChar(f) { var df=f; df=df.replace(/\\/g, '\\\\'); df=df.replace(/\//g, '\\\/'); df=df.replace(/\[/g, '\\\['); df=df.replace(/\]/g, '\\\]'); df=df.replace(/\(/g, '\\\('); df=df.replace(/\)/g, '\\\)'); df=df.replace(/\{/g, '\\\{'); df=df.replace(/\}/g, '\\\}'); df=df.replace(/\/g, '\\\>'); df=df.replace(/\|/g, '\\\|'); df=df.replace(/\*/g, '\\\*'); df=df.replace(/\?/g, '\\\?'); df=df.replace(/\+/g, '\\\+'); df=df.replace(/\^/g, '\\\^'); df=df.replace(/\$/g, '\\\$'); return df; } function rePhone(f) { var df=rpChar(f); df=df.replace(/d/gi, '\\d'); df=df.replace(/w/gi, '(\\w|\\d)'); return new RegExp('^'+df+'$'); } function reDate(f) { var df=rpChar(f); df=df.replace(/dd/gi, '\\d\\d'); df=df.replace(/mm/gi, '\\d\\d'); df=df.replace(/yyyy/gi, '\\d\\d\\d\\d'); return new RegExp('^'+df+'$'); } function reCharNM(n,m) { return new RegExp("\^[\\w\\-]{"+n+","+m+"}\$"); } function reNumberN(n,mode) { return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{1,"+n+"}\$"); } function reNumberN2(n,mode) { return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{"+n+"}\$"); } function reNumberNM(n,m,mode) { return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{1,"+n+"}(\\.\\d{1,"+m+"})?\$"); } function reNumberNM2(n,m,mode) { return new RegExp("\^"+(mode!=0?"(\\+\|-)?":"")+"\\d{"+n+"}\\.\\d{"+m+"}\$"); } // wrapper functions function _alertIt(msg, mode) { if (mode) { totalAlert+=msg+"\n"; } else { totalAlert=""; alert(msg); } } function _checkIt(re, field, msg, mode) { if (!re.test(field.value)) { _alertIt(msg, mode); if (field.select) { field.select(); } if (field.focus) { field.focus(); } return (mode && mode==1)?true:false; } return true; } function noErrors() { if (totalAlert=="") { return true; } else { alert(totalAlert); totalAlert=""; return false; } } // the checking functions function goodPasswords(field1, field2, msg1, msg2, mode) { if (nonBlank(field1, msg1, mode?2:0) && nonBlank(field2, msg1, mode?2:0)) { if (field1.value == field2.value) { return true; } else { _alertIt(msg2, mode); } } return (mode && mode==1)?true:false; } function goodPasswordsLen(field1, field2, n, m, msg1, msg2, msg3, mode) { if (nonBlank(field1, msg1, mode?2:0) && nonBlank(field2, msg1, mode?2:0)) { if (field1.value == field2.value) { if (goodCharLen(n, m, field1, msg3, mode?2:0)) { return true; } } else { _alertIt(msg2, mode); } } return (mode && mode==1)?true:false; } function goodEMails(field1, field2, msg1, msg2, mode) { if (goodEMail(field1, msg1, mode?2:0) && goodEMail(field2, msg1, mode?2:0)) { if (field1.value == field2.value) { return true; } else { _alertIt(msg2, mode); } } return (mode && mode==1)?true:false; } function goodPhone(pf, field, msg, mode) { return _checkIt(rePhone(pf), field, msg, mode); } function goodPostalCA(field, msg, mode) { return _checkIt(rePostalCA, field, msg, mode); } function goodDate(df, field, msg, mode) { if (_checkIt(reDate(df), field, msg, mode?2:0)) { var di=field.value; var y4=df.search(/yyyy/i), y=di.substring(y4, y4+4)-0; var m2=df.search(/mm/i), m=di.substring(m2, m2+2)-1; var d2=df.search(/dd/i), d=di.substring(d2, d2+2)-0; var dd=new Date(y, m, d); if (y==dd.getFullYear() && m==dd.getMonth() && d==dd.getDate()) { return true; } else { _alertIt(msg, mode); field.select(); field.focus(); } } return (mode && mode==1)?true:false; } function goodIP(field, msg, mode) { return _checkIt(reIP, field, msg, mode); } function goodChar(field, msg, mode) { return _checkIt(reChar, field, msg, mode); } function goodEMail(field, msg, mode) { return _checkIt(reEMail, field, msg, mode); } function goodInt(field, msg, mode) { return _checkIt(reInt, field, msg, mode); } function goodSignedInt(field, msg, mode) { return _checkIt(reSignedInt, field, msg, mode); } function goodFloat(field, msg, mode) { return _checkIt(reFloat, field, msg, mode); } function goodSignedFloat(field, msg, mode) { return _checkIt(reSignedFloat, field, msg, mode); } function goodIntLen(n, field, msg, mode) { return _checkIt(reNumberN(n,0), field, msg, mode); } function goodSignedIntLen(n, field, msg, mode) { return _checkIt(reNumberN(n,1), field, msg, mode); } function goodIntLen2(n, field, msg, mode) { return _checkIt(reNumberN2(n,0), field, msg, mode); } function goodSignedIntLen2(n, field, msg, mode) { return _checkIt(reNumberN2(n,1), field, msg, mode); } function goodCharLen(n, m, field, msg, mode) { return _checkIt(reCharNM(n,m), field, msg, mode); } function goodFloatLen(n, m, field, msg, mode) { return _checkIt(reNumberNM(n,m,0), field, msg, mode); } function goodSignedFloatLen(n, m, field, msg, mode) { return _checkIt(reNumberNM(n,m,1), field, msg, mode); } function goodFloatLen2(n, m, field, msg, mode) { return _checkIt(reNumberNM2(n,m,0), field, msg, mode); } function goodSignedFloatLen2(n, m, field, msg, mode) { return _checkIt(reNumberNM2(n,m,1), field, msg, mode); } function _rangeIt(field, r1, r2, msg, mode) { if (field.value>=r1 && field.value<=r2) { return true; } else { _alertIt(msg, mode); field.select(); field.focus(); return (mode && mode==1)?true:false; } } function rangeInt(field, r1, r2, msg, mode) { if (goodInt(field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeSignedInt(field, r1, r2, msg, mode) { if (goodSignedInt(field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeFloat(field, r1, r2, msg, mode) { if (goodFloat(field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeSignedFloat(field, r1, r2, msg, mode) { if (goodSignedFloat(field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeIntLen(n, field, r1, r2, msg, mode) { if (goodIntLen(n, field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeSignedIntLen(n, field, r1, r2, msg, mode) { if (goodSignedIntLen(n, field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeIntLen2(n, field, r1, r2, msg, mode) { if (goodIntLen2(n, field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeSignedIntLen2(n, field, r1, r2, msg, mode) { if (goodSignedIntLen2(n, field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeFloatLen(n, m, field, r1, r2, msg, mode) { if (goodFloatLen(n, m, field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeSignedFloatLen(n, m, field, r1, r2, msg, mode) { if (goodSignedFloatLen(n, m, field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeFloatLen2(n, m, field, r1, r2, msg, mode) { if (goodFloatLen2(n, m, field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function rangeSignedFloatLen2(n, m, field, r1, r2, msg, mode) { if (goodSignedFloatLen2(n, m, field, msg, mode?2:0)) { return _rangeIt(field, r1, r2, msg, mode); } return (mode && mode==1)?true:false; } function _dd(n) { return (n<10)?"0"+n:""+n; } function _getOffset(n) { var d=new Date(); if (n!=0) { d.setTime(d.getTime()+n*86400000); } return d.getFullYear()+""+_dd(d.getMonth()+1)+""+_dd(d.getDate())+""; } function _stringIt(df, d) { var y4=df.search(/yyyy/i), m2=df.search(/mm/i), d2=df.search(/dd/i); return d.substring(y4, y4+4)+d.substring(m2, m2+2)+d.substring(d2, d2+2); } function rangeDate(df, field, r1, r2, msg, mode) { if (goodDate(df, field, msg, mode?2:0)) { var d=_stringIt(df, field.value); var r1x="", r2x=""; if (r1.search(/^\d+$/)!=-1) { r1x=_getOffset(r1-0); } else { r1x=_stringIt(df, r1); } if (r2.search(/^\d+$/)!=-1) { r2x=_getOffset(r2-0); } else { r2x=_stringIt(df, r2); } if (dr2x) { _alertIt(msg, mode); field.select(); field.focus(); } else { return true; } } return (mode && mode==1)?true:false; } function goodDateRange(df, field1, field2, msg, mode) { if (goodDate(df, field1, msg, mode?2:0) && goodDate(df, field2, msg, mode?2:0)) { if (_stringIt(df, field1.value)>_stringIt(df, field2.value)) { _alertIt(msg, mode); field1.focus(); } else { return true; } } return (mode && mode==1)?true:false; } function goodDateRange2(df, field1, field2, msg, mode) { if (goodDate(df, field1, msg, mode?2:0) && goodDate(df, field2, msg, mode?2:0)) { if (_stringIt(df, field1.value)>=_stringIt(df, field2.value)) { _alertIt(msg, mode); field1.focus(); } else { return true; } } return (mode && mode==1)?true:false; } function goodHexColor(field, msg, mode) { return _checkIt(reHexColor, field, msg, mode); } function nonBlank(field, msg, mode) { if (field.type) { if (/file|select|text|password/.test(field.type)) { return _checkIt(reNonBlank, field, msg, mode); } else if (/radio|checkbox/.test(field.type)) { if (field.checked) { return true; } else { _alertIt(msg, mode); field.focus(); return (mode && mode==1)?true:false; } } else { _alertIt("Invalid field for nonBlank() checking", mode); return (mode && mode==1)?true:false; } } else if (field.length && field[0].type && /radio|checkbox/.test(field[0].type)) { for (var i=0; i=10) { sum+=(tproduct%10)+1; } else { sum+=tproduct; } if (mul==1) { mul++; } else { mul--; } } if ((sum%10)==0) { return true; } else { _alertIt(msg, mode); return (mode && mode==1)?true:false; } } } function goodVisa(field, msg, mode) { if ((field.value.length==16 || field.value.length==13) && field.value.substring(0,1)==4) { return goodCreditCard(field, msg, mode); } else { _alertIt(msg, mode); return (mode && mode==1)?true:false; } } function goodMasterCard(field, msg, mode) { var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2); if (field.value.length==16 && firstdig==5 && (seconddig>=1 && seconddig<=5)) { return goodCreditCard(field, msg, mode); } else { _alertIt(msg, mode); return (mode && mode==1)?true:false;; } } function goodAmericanExpress(field, msg, mode) { var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2); if (field.value.length==15 && firstdig==3 && (seconddig==4 || seconddig==7)) { return goodCreditCard(field, msg, mode); } else { _alertIt(msg, mode); return (mode && mode==1)?true:false;; } } function goodDinersClub(field, msg, mode) { var firstdig=field.value.substring(0,1), seconddig=field.value.substring(1,2); if (field.value.length==14 && firstdig==3 && (seconddig==0 || seconddig==6 || seconddig==8)) { return goodCreditCard(field, msg, mode); } else { _alertIt(msg, mode); return (mode && mode==1)?true:false;; } } function goodCarteBlanche(field, msg, mode) { return goodDinersClub(field, msg, mode); } function goodDiscover(field, msg, mode) { var first4digs=field.value.substring(0,4); if (field.value.length==16 && first4digs=="6011") { return goodCreditCard(field, msg, mode); } else { _alertIt(msg, mode); return (mode && mode==1)?true:false;; } } function goodEnRoute(field, msg, mode) { var first4digs=field.value.substring(0,4); if (field.value.length==15 && (first4digs=="2014" || first4digs=="2149")) { return goodCreditCard(field, msg, mode); } else { _alertIt(msg, mode); return (mode && mode==1)?true:false;; } } function goodJCB(field, msg, mode) { var first4digs=field.value.substring(0,4); if (field.value.length==16 && (first4digs=="3088" || first4digs=="3096" || first4digs=="3112" || first4digs=="3158" || first4digs=="3337" || first4digs=="3528")) { return goodCreditCard(field, msg, mode); } else { _alertIt(msg, mode); return (mode && mode==1)?true:false;; } } function notSubmitted(msg) { if (submitCounter==0) { submitCounter=1; return true; } else { alert(msg); return false; } } function goodURL(field, msg, mode) { return _checkIt(reURL, field, msg, mode); }