%option explicit
Dim errorMsg
Dim FirstName, LastName, Age, Email, Phone
Dim okFirstName, okLastName, okEmail, okPhone
InitValidation
if FormSubmitted() then
FillFormFromPost
if ValidateForm() then
Server.Transfer "gdform.asp"
else
errorMsg = "Please complete the required fields below"
end if
end if
%>
Contact Us
<%
Sub FillFormFromPost()
FirstName = Request.Form("01FirstName")
LastName = Request.Form("02LastName")
Email = Request.Form("Email")
Phone = Request.Form("4Phone")
'add new variables here
End Sub
Sub InitValidation()
okFirstName = true
okLastName = true
okEmail = true
okPhone = true
'add new true variables here
End Sub
Function ValidateForm()
dim ValidForm : ValidForm = true
okFirstName = ValidRequiredField(FirstName)
ValidForm = okFirstName and ValidForm
okLastName = ValidRequiredField(LastName)
ValidForm = okLastName and ValidForm
okEmail = ValidEmailField(Email)
ValidForm = okEmail and ValidForm
okPhone = ValidRequiredField(Phone)
ValidForm = okPhone and ValidForm
'add more form validation here
ValidateForm = ValidForm
End Function
Sub DoSomething
' do whatever you want here - write file, send email
End Sub
'''''Validation Functions - don't change these, don't edit below this line
Function ValidRequiredField(byval field)
ValidRequiredField = false
if Len(field) > 0 then
ValidRequiredField = true
end if
End Function
Function ValidEmailField(byval field)
Dim myReg
Set myReg = New RegExp
myReg.IgnoreCase = True
myReg.Pattern = "^[\w-\.]+@[\w-\.]+\.\w+$"
ValidEmailField = myReg.Test(field)
End Function
Function FormSubmitted()
FormSubmitted = false
if Request.Form.Count > 0 then
FormSubmitted = true
end if
End Function
%>