<%@ language = VBScript %> <% const numFields = 5 dim errorArray() redim preserve errorArray(numFields) if request.form("isSubmitted") <> "yes" then ErrorMsg = "Fields marked as * are required before form submission.
" else name1 = request.form("name1") email = request.form("email") phone = request.form("phone") enquiry = request.form("enquiry") details = request.form("details") wherefrom = request.form("wherefrom") website = request.form("website") webaddress = request.form("webaddress") ErrorMsg = "" dim re, results set re = New RegExp 'Name re.Pattern = "^[^0-9\/><\.,\\!\^\$\*\+\?@#%&\(\);:\[\]\{\}=""']+$" re.Global = True re.IgnoreCase = True results = re.Test(name1) if results then errorArray(0) = "False" else errorArray(0) = "True" ErrorMsg = ErrorMsg & "- Your NAME is missing.
" end if 'Email re.Pattern = "^\w+@\w+\.\w+" results = re.Test(email) if results then errorArray(1) = "False" else errorArray(1) = "True" ErrorMsg = ErrorMsg & "- A valid contact EMAIL address is required.
" end if 'Telephone ' Formats a given 10 digit number into a nice looking phone number Function FormatPhoneNumber(strNumber) Dim strInputp ' String to hold our entered number Dim strTemp ' Temporary string to hold our working text Dim strCurrentChar ' Var for storing each character for eval. Dim I ' Looping var ' Uppercase all characters for consistency strInputp = UCase(strNumber) ' Strip out all characters except for digits 0 to 9 before proceeding. For I = 1 To Len(strInputp) strCurrentChar = Mid(strInputp, I, 1) ' Numbers (0 to 9) If Asc("0") <= Asc(strCurrentChar) And Asc(strCurrentChar) <= Asc("9") Then strTemp = strTemp & strCurrentChar End If Next 'I ' Swap strTemp back to strInput for next set of validation ' Clear strTemp strInputp = strTemp strTemp = "" ' Error catch to make sure strInput is proper length now that ' manipulation is complete If Not Len(strInputp) = 10 Then Err.Raise 1, "FormatPhoneNumber function", _ "- The PHONE number you have supplied requires 10 digits.
" End If ' If an error occurred then the rest of this function won't get processed! ' Building the output string formatted to requirements. 'Process the first 2 characters in brackets and place them in brackets, start at '3rd character stored in strInput and process the following 4 characters, insert 'a dash and then process the remaining 4 characters. eg. (xx) xxxx-xxxx strTemp = "(" ' "(" strTemp = strTemp & Left(strInputp, 4) ' Area code strTemp = strTemp & ") " ' ") " strTemp = strTemp & Mid(strInputp, 5, 3) ' Exchange strTemp = strTemp & "-" ' "-" strTemp = strTemp & Right(strInputp, 3) ' 4 digit part ' Set return value FormatPhoneNumber = strTemp End Function '***** END FUNCTION AREA ***** if (isempty(request.form("phone")) or request.form("phone") = "") then errorArray(2) = "True" ErrorMsg = ErrorMsg & "- A PHONE number is required.
" else errorArray(2) = "False" end if On Error Resume Next If request.form("phone")<>"" then FormatPhoneNumber(request.form("phone")) If Err.number then errorArray(3) = "True" ErrorMsg = ErrorMsg & Err.description else errorArray(3) = "False" end if end if 'Comments if isempty(request.form("details")) or request.form("details") = "" then errorArray(4) = "True" ErrorMsg = ErrorMsg & "- Your COMMENTS are required.
" else errorArray(4) = "False" end if 'Website Message if website = "Yes" and (isempty(request.form("webaddress")) or request.form("webaddress") = "") then 'websitemessage = "I have a domain name, but do not wish to disclose it to your company at this time." elseif website = "No" and (isempty(request.form("webaddress")) or request.form("webaddress") = "") then websitemessage = "I do not have a domain name at present, but understand that Naked Egg Web Design can arrange this for me if requested." else websitemessage = "I have a domain name and its address is http://"&webaddress&"." end if if ErrorMsg<>"" then ErrorMsg = "The form was not submitted as the following field/s contained errors:
"&ErrorMsg end if end if 'If there are no error messages if request.form("isSubmitted") = "yes" and ErrorMsg = "" then ErrorMsg = "Thank you - Your enquiry has been submitted.
A customer service representative will contact you shortly.
" 'Email Message ' EMAIL MESSAGE COMPILATION EmailMessage = "Hi,"&chr(13)&chr(13) EmailMessage = EmailMessage & "I was browsing through your website and now have the following comment/s to make:"&chr(13) EmailMessage = EmailMessage & "========================="&chr(13) EmailMessage = EmailMessage & details&chr(13) EmailMessage = EmailMessage & "========================="&chr(13)&chr(13) EmailMessage = EmailMessage & "I heard about NEWD from:-"&wherefrom&chr(13)&chr(13) EmailMessage = EmailMessage & websitemessage&chr(13)&chr(13) EmailMessage = EmailMessage & "With best regards, I look forward to your response to the information above at your earliest convenience."&chr(13)&chr(13) EmailMessage = EmailMessage & name1&chr(13) EmailMessage = EmailMessage & "Phone: "&FormatPhoneNumber(phone)&chr(13) EmailMessage = EmailMessage & "Email: "&email ' MAIL SUBROUTINE ' Mail variables ToEmail = "info@newd.com.au" txtSubject = enquiry strHost = "mail.newd.com.au" Dim CDOMail ' Mail Send sub-routine Set CDOMail = Server.CreateObject("CDONTS.NewMail") CDOMail.From = request("email") CDOMail.To = ToEmail CDOMail.CC = request("email") CDOMail.Subject = txtSubject CDOMail.Body = EmailMessage CDOMail.Send Set CDOMail = nothing end if %> Naked Egg Web Design | Contact Us
Note: <% if ErrorMsg <> "" then%> <%= ErrorMsg %>
<% end if %>
*Name:
 
*Email:
 
*Phone:
 
Enquiry:
 
*Comments:
Where did you hear about NEWD?:  
Do you currently have a website?:   Yes /> No />
(Please choose one)
If so, what is its address?:
http://
 
CONTACT DETAILS
   
Home Page
Web Design
Portfolio
Client Area