I'm pretty sure he was looking for a server side validator. It seems like I've seen that before. Maybe from Jim Davis? Anyway... some good stuff in there.
..:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -----Original Message----- From: Doug Brown [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 22, 2006 11:51 PM To: CF-Talk Subject: Re: A good email validator? Another nice one I use. This has several functions. function custRound(x,places){ return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places) } function emailValidate(email, isRequired ){ var required if( isRequired != null ) required = isRequired; else required = "YES"; email.value = f_trimmer( email.value ); if ( ( email.value == "" ) && ( required.toUpperCase() == "YES" ) ){ alert("You Must enter an email address"); email.select(); email.focus(); return false; } if ( ( ( email.value.indexOf("@") == -1 ) || ( email.value.indexOf(".") == -1 ) || ( email.value.indexOf(" ") != -1 ) ) && ( email.value != "" ) ){ alert( "\"" + email.value + "\"" + " is not a valid email address." ); return false; }else return true; } function f_trimmer(thisstring){ while(thisstring.charAt(0)==" "){ thisstring=thisstring.substring(1,thisstring.length) } thisstring=r_trimmer(thisstring) return thisstring } function r_trimmer(thisstring){ while(thisstring.charAt(thisstring.length-1)==" "){ thisstring=thisstring.substring(0,(thisstring.length-1)) } return thisstring } function checkForValue(number,exponent){ var pnumber = number * 1; if (!pnumber && pnumber != 0){ return -1; } if((exponent == 0) && (pnumber >= 0)) return 0; //var result = pnumber / Math.pow(10,(exponent-1)); //alert(result); if ((pnumber / Math.pow(10,(exponent-1))) < 1) return 1; return 0; } function valNumProp(formField,exponent,fildName){ var exponentError = "You Must Enter " + exponent + " digit(s)."; var trimError = "You must enter a value"; var NaNError = "Letters and Spaces are not Allowed."; //trim space check formField.value = f_trimmer(formField.value); if(formField.value == ""){ alert("Error Validating " + fildName + ":\n" + trimError); formField.focus(); return false; } //return check For value error var err = checkForValue(formField.value,exponent); //check for NaN error if (err == -1){ alert("Error Validating " + fildName + ":\n" + NaNError); formField.focus(); return false; } //check for number of digits error if (err == 1){ alert("Error Validating " + fildName + ":\n" + exponentError); formField.focus(); return false; } return true; } function evaluate_Number_Element(element,formField,elementName,exponent){ var exponentError = "You Must Enter " + exponent + " digit(s)."; var trimError = "You must enter a value"; var NaNError = "Letters and Spaces are not Allowed."; //trim space check element = f_trimmer(element); if(element == ""){ alert("Error Validating " + elementName + ":\n" + trimError); formField.focus(); return false; } //return check For value error var err = checkForValue(element,exponent); //check for NaN error if (err == -1){ alert("Error Validating " + elementName + ":\n" + NaNError); formField.focus(); return false; } //check for number of digits error if (element.length != exponent && exponent != 0 ){ alert("Error Validating " + elementName + ":\n" + exponentError); formField.focus(); return false; } return true; } function textValidate(field,fieldName,defaultSetting){//default setting is help info preloaded into field field.value = f_trimmer(field.value); //will return error if value has not been changed by EU error = 0; if(defaultSetting != null){ if(field.value == f_trimmer(defaultSetting)) error = 1; } if(field.value == '') error = 1; if(error == 1 && fieldName != "noError"){ alert("You must enter a " + fieldName); field.select(); field.focus(); return false; } if(error == 1){ return false; } else return true; } function setMatch(optionList,searchText){ var matchFound = false; var optionLength = optionList.length; var item; for (var i=0; i < optionLength; i++){ item = optionList.options[i].value.toUpperCase(); if (item == searchText.toUpperCase()){ optionList.options[i].selected = true; matchFound = true; break; } } if(matchFound == false){ optionList.options[0].selected = true; } } function selectValidateMatch(optionList,compareValue,message){ if(optionList.options[optionList.selectedIndex].value.toUpperCase() != compareValue.toUpperCase() ){ if(message != null) alert(message); optionList.focus(); return false; } return true; } function selectValidate(optionList,fieldName,showError){ if(optionList.options[optionList.selectedIndex].value == "none"){ if(fieldName != "none") alert("You must select a " + fieldName); optionList.focus(); return false; } return true; } function trimField(field){ field.value = f_trimmer(field.value); } function dateValidate( dateIn, fieldName ){ if( textValidate( dateIn, fieldName ) == false ) return 2;//return 2 if null field var dateField = dateIn.value;//all ready trimmed from textValidate var leftStringStart = 0; var i = 0; var n = 0; var datePart = new Array(); while(i != dateField.length){ character = dateField.charAt(i); if( character == "." || character == "/" || character == "-"){ datePart[n] = dateField.substring(leftStringStart,i); leftStringStart = i + 1; n++; } else{ if(character == " "){ alert("please remove all spaces from date field"); dateIn.focus(); return 1; } if( ( character != "0" ) && ( !parseInt( character ) ) ){ alert("\"" + character + "\" is not a valid character for a date value\n Mask = \"mm/dd/yy(yy)\""); dateIn.focus(); return 1; } } i++; } datePart[n] = dateField.substring(leftStringStart,i); if( n != 2){ alert( "Can't parse string to Date\n Mask = \"mm/dd/yy(yy)\"" ); dateIn.focus(); return 1; } //check month range if(datePart[0].charAt(0) == "0")//fix for leading 0 bug datePart[0] = datePart[0].substring(1,2); if( datePart[0].length != 1 && datePart[0].length != 2 ){ alert( "Month Value must be 1 or 2 digits" ); dateIn.focus(); return 1; } n = parseInt( datePart[0] ); if ( n < 1 || n > 12 ){ alert( "month value \"" + n + "\"out of range"); dateIn.focus(); return 1; } //check day range if(datePart[1].charAt(0) == "0")// fix for leading 0 bug datePart[1] = datePart[1].substring(1,2); if( datePart[1].length != 1 && datePart[1].length != 2 ){ alert( "Day Value must be 1 or 2 digits" ); dateIn.focus(); return 1; } n = parseInt( datePart[1] ); if ( n < 1 || n > 31 ){ alert( "day value \"" + n + "\"out of range"); dateIn.focus(); return 1; } //check year range if( datePart[2].length != 2 && datePart[2].length != 4 ){ alert( "Year Value must be 2 or 4 digits" ); dateIn.focus(); return 1; } if(datePart[2].charAt(0) == "0")//fix for leading 0 bug datePart[2] = datePart[2].substring(1,2); n = parseInt( datePart[2] ); if( n < 50 ) n += 2000; if( n < 100 ) n += 1900; if( n < 1950 ){ alert( "Year in date value out of range"); dateIn.focus(); return 1; } if( n > 2050 ){ alert( "Year in date value out of range"); dateIn.focus(); return 1; } var dateString = datePart[0] + "/" + datePart[1] + "/" + n; var validationDate = new Date(dateString); if ( parseInt( datePart[1] ) != validationDate.getDate() ){ alert( "Day value out of range for this month and year" ); dateIn.focus(); return 1; } dateIn.value = dateString; return 0; } function moneyValidate(field,fieldName){ field.value = f_trimmer(field.value); if( field.value == "" ){ if(fieldName != "noError"){ alert( "You must enter a " + fieldName ); field.focus(); } return 2; } var wMoney = field.value; var i = 0; var rMoney = ""; var err = 0; var n = 0; var wChar = ""; for(i;i < wMoney.length;i++){ wChar = wMoney.charAt(i); if( wChar == " " ){ alert("Please Remove all spaces from money field"); field.focus(); return 1; } if( ( parseInt( wChar ) ) || ( wChar == 0 ) ){ rMoney = rMoney + wChar; continue; } if( ( i == 0 ) && ( wChar == "$" ) ){ continue; } if( ( wChar == "," ) && ( n == 0 ) ) continue; if( ( wChar == "." ) && ( n == 0 ) ){ n = i; rMoney = rMoney + wChar; continue; } if( ( wChar == ".") ){ alert( "Too many decimal points in Money Field Please fix and resubmit"); field.focus(); return 1; } alert( "\"" + wChar + "\" Is not a valid symbol for money format\n Ex. $##,###.##" ) field.focus(); return 1; } if ( ( ( n + 1 ) < ( wMoney.length - 2 ) ) && (n != 0) ){ alert("Money Field Has too many digits after decimal\nPlease round to nearest cent" ); field.focus(); return 1; } field.value = rMoney; return 0; } function stripSpaces(field){ var workingText = ""; var i = 0; for( i; i < field.length ; i++ ){ if( field.charAt(i) != " " ) workingText = workingText + field.charAt(i); } return workingText; } function stripComma(field){ var workingText = ""; var i = 0; for( i; i < field.length ; i++ ){ if( field.charAt(i) != "," ) workingText = workingText + field.charAt(i); } return workingText; } function stripSymbol(field, symbol ){ var workingText = ""; var i = 0; for( i; i < field.length ; i++ ){ if( field.charAt(i) != symbol ) workingText = workingText + field.charAt(i); } return workingText; } function replaceSymbol(field, symbol, replacement ){ var workingText = ""; var i = 0; for( i; i < field.length ; i++ ){ if( field.charAt(i) != symbol ) workingText = workingText + field.charAt(i); else workingText = workingText + replacement; } return workingText; } function symbolError(symbol,formField,Mask){ var SymbolHead = "Invalid Phone Number"; var SymbolTail = " IE: 123-456-7890"; alert(SymbolHead + SymbolTail); formField.select(); formField.focus(); } function symbolOutError(formField,Mask){ alert("Symbols out of sequence" + Mask); formField.select(); formField.focus(); } function phoneValidate(phoneField){ var Mask = "IE: 123-456-7890"; phoneField.value = stripSpaces(phoneField.value); phoneField.value = phoneField.value.toLowerCase(); phoneField.value = stripSymbol( phoneField.value, "(" ); phoneField.value = replaceSymbol( phoneField.value, "/", "-" ); phoneField.value = replaceSymbol( phoneField.value, "/", "." ); phoneField.value = replaceSymbol( phoneField.value, ")", "-" ); var slashPosition = phoneField.value.indexOf("-"); var dashPosition = phoneField.value.indexOf("-", slashPosition + 1 ); var xPosition = phoneField.value.indexOf("x"); if( slashPosition == -1 ){ symbolError(phoneField,Mask); return false; } if( dashPosition == -1 ){ symbolError("-",phoneField,Mask); return false; } if ( slashPosition > dashPosition ){ symbolOutError(phoneField,Mask); return false; } if ( ( xPosition != -1 ) && ( dashPosition > xPosition ) ){ symbolOutError(phoneField,Mask); return false; } var endSufixPosition = 0; if( xPosition == -1 ) endSufixPosition = phoneField.value.length; else endSufixPosition = xPosition; var areaCode = phoneField.value.substring(0,slashPosition); var prefix = phoneField.value.substring(slashPosition + 1,dashPosition); var sufix = phoneField.value.substring(dashPosition + 1,endSufixPosition); var ext = f_trimmer( phoneField.value.substring(endSufixPosition + 1,phoneField.value.length) ); /* alert(areaCode + "\n" + prefix + "\n" + sufix + "\n" + ext + "\n"); */ //evaluate_Number_Element(element,formField,elementName,exponent) if( evaluate_Number_Element( areaCode,phoneField,"Area Code",3 ) == false ) return false; if( evaluate_Number_Element(prefix,phoneField,"prefix",3) == false) return false; if( evaluate_Number_Element(sufix,phoneField,"sufix",4) == false) return false; if( ( phoneField.value.indexOf("x") == 12 ) && ( evaluate_Number_Element(ext,phoneField,"Extention",0) == false ) ) return false; return true; } Doug ----- Original Message ----- From: "Ian Skinner" <[EMAIL PROTECTED]> To: "CF-Talk" <[email protected]> Sent: Wednesday, November 22, 2006 2:08 PM Subject: RE: A good email validator? > I've used this one for quite some time [attached] > > > This list strips attachments. > > > -------------- > Ian Skinner > Web Programmer > BloodSource > www.BloodSource.org > Sacramento, CA > > --------- > | 1 | | > --------- Binary Soduko > | | | > --------- > > "C code. C code run. Run code run. Please!" > - Cynthia Dunning > > Confidentiality Notice: This message including any > attachments is for the sole use of the intended > recipient(s) and may contain confidential and privileged > information. Any unauthorized review, use, disclosure or > distribution is prohibited. If you are not the > intended recipient, please contact the sender and > delete any copies of this message. > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:261542 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

