<%@ Language=VBScript %><% Function PCase(strInput) Dim iPosition ' Our current position in the string (First character = 1) Dim iSpace ' The position of the next space after our iPosition Dim strOutput ' Our temporary string used to build the function's output ' Set our position variable to the start of the string. iPosition = 1 ' We loop through the string checking for spaces. ' If there are unhandled spaces left, we handle them... Do While InStr(iPosition, strInput, " ", 1) <> 0 ' To begin with, we find the position of the offending space. iSpace = InStr(iPosition, strInput, " ", 1) strOutput = strOutput & UCase(Mid(strInput, iPosition, 1)) strOutput = strOutput & LCase(Mid(strInput, iPosition + 1, iSpace - iPosition)) iPosition = iSpace + 1 Loop strOutput = strOutput & UCase(Mid(strInput, iPosition, 1)) strOutput = strOutput & LCase(Mid(strInput, iPosition + 1)) ' That's it - Set our return value and exit PCase = strOutput End Function Function validChar(strInput) DIM iposition ' Current position of the character or cursor validChar = true 'loop through each character in the string and validate that it is a number or integer For iposition=1 To Len(trim(strInput)) if InStr(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", mid(strInput,iposition,1), 1) = 0 then validChar = false Exit For end if Next end Function Function ValidateField(sFieldValue, sFieldType) Dim bFieldIsOkay ' defaut it to true bFieldIsOkay = True ' go to the field name to validate the entry Select Case LCase(sFieldType) Case "firstname" If Len(sFieldValue) = 0 or not validChar(sFieldValue) Then bFieldIsOkay = False Case "lastname" If Len(sFieldValue) = 0 or not validChar(sFieldValue) Then bFieldIsOkay = False case "areacode" If Len(sFieldValue) <> 3 or not isnumeric(sFieldValue) Then bFieldIsOkay = False end If case "phone" If Len(sFieldValue) <> 7 or not isnumeric(sFieldValue) Then bFieldIsOkay = False end If Case "email" If Len(sFieldValue) < 5 Then bFieldIsOkay = False Else If Instr(1, sFieldValue, " ") <> 0 Then bFieldIsOkay = False Else If InStr(1, sFieldValue, "@") < 2 Then bFieldIsOkay = False Else If InStrRev(sFieldValue, ".") < InStr(1, sFieldValue, "@") + 2 Then bFieldIsOkay = False End If End If End If End If Case "else" 'if an unknown type gets in reject form! bFieldIsOkay = False End Select ValidateField = bFieldIsOkay End Function Function SendEmail() ' Email the contents of the form to Dermatopathology Dim objCDONTS ' Email object Dim strFromName ' From persons' real name Dim strFromEmail, strToEmail ' Email addresses Dim strSubject, strBody ' Message Dim strThisPage ' This page's URL Dim strReferringPage ' The referring page's URL Dim bValidInput ' A boolean indicating valid parameters ' Retrieve this page name and referring page name strThisPage = Request.ServerVariables("SCRIPT_NAME") strReferringPage = Request.ServerVariables("HTTP_REFERER") ' Read in and set the initial values of our message parameters strFromName = PCase(CStr(Request.Form("firstname")))&" "&PCase(CStr(Request.Form("lastname"))) if Request.Form("email") <> "" and not dictFields(Lcase("email")) Then strFromEmail = Request.Form("email") else strFromEmail = "Unknown@lwmilby.com" end if strToEmail = "lwmilby@lwmilby.com" strSubject = "lwmilby.com contact form submission" strBody = vbCrLf & "The following information was filled out at lwmilby.com on " & date() & " " & time() & vbCrLf strBody = strBody & vbCrLf strBody = strBody & "First Name : " & PCase(CStr(Request.form("firstname"))) & vbCrLf strBody = strBody & "Last Name : " & PCase(CStr(Request.form("lastname"))) & vbCrLf strBody = strBody & "Middle Initial : " & PCase(CStr(Request.form("middleinit"))) & vbCrLf strBody = strBody & "Company : " & PCase(CStr(Request.form("company"))) & vbCrLf strBody = strBody & "Address : " & PCase(CStr(Request.form("street"))) & vbCrLf strBody = strBody & " " & PCase(CStr(Request.form("city"))) & " " & ucase(Request.form("state"))& ", " & Request.form("zip") & vbCrLf strBody = strBody & "E-mail : " & request.form("email") & vbCrLf strBody = strBody & "Phone : " & Request.form("areacode")& "-" & Request.form("phone")& vbCrLf strBody = strBody & "Area of Interest : " & Request.form("interest2") & vbCrLf strBody = strBody & "Booth Size : " & Request.form("boothsize") & vbCrLf strBody = strBody & "Comments : " & Request.form("comments") & vbCrLf ' Set up our email object and send the message Set objCDONTS = Server.CreateObject("CDONTS.NewMail") objCDONTS.From = strFromName & " <" & strFromEmail & ">" objCDONTS.To = strToEmail objCDONTS.Subject = strSubject objCDONTS.Body = strBody objCDONTS.Importance = 1 objCDONTS.Send Set objCDONTS = Nothing End Function %> <%' Begin Runtime Code Dim Field 'looping variable Dim dictFields 'dictionary for failed fields Set dictFields = Server.CreateObject("Scripting.Dictionary") For Each Field in Request.Form If ValidateField(Request.Form(Field), Field) = False Then dictFields.Add LCase(Field), True End If Next 'Field If Request.Form.Count <> 0 And not dictFields(Lcase("firstname")) And not dictFields(Lcase("lastname")) And not dictFields(Lcase("areacode"))and not dictFields(Lcase("phone")) Then %> Thanks for contacting us! We will respond as quickly as possible, if necessary. <% SendEmail() ElseIf Request.Form.Count <> 0 And not dictFields(Lcase("firstname")) And not dictFields(Lcase("lastname")) and not dictFields(Lcase("email")) And dictFields(Lcase("areacode"))and dictFields(Lcase("phone")) Then %> Thanks for contacting us! We will respond as quickly as possible, if necessary. <% SendEmail() Elseif dictFields.Count <> 0 and Request.Form.Count <> 0 Then %>

CONTACT US
Please provide and/or correct the following information.

" method="post" name="TheForm">
first name:
"> required
last name:
"> required
phone:
"> - ">
email:
"> required if no phone number

"> "> "> "> "> "> "> "> ">

 

<% Else ' Show thw form with checks if appropriate %>

CONTACT US
Feel free to contact LW Milby with any questions!
Required fields: name, and phone or email address

" method="post" name="TheForm">
first name:
required
middle initial:
last name:
required
company name:
street address:
city:
state:
zip:
phone:
-
email:
required if no phone number
area of interest:
booth size:
(if applicable)

 

comment area:

     

 

<% End If %>

A Native American Owned Company

1701 Dalton Dr.    New Carlisle, Ohio 45344
voice: (937) 849-9100  fax: (937) 849-9099