1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Please help with form validation

Discussion in 'C#' started by tatanka, Apr 28, 2008.

  1. #1
    Hi Guys, I'm new to asp and wondering if you can help me out. I have this code below and need to make the fields required before it sends the email to me. Can you please advise how to do it?


    <%

    Option Explicit



    Dim objErrMail

    Dim strTo

    Dim strFrom

    Dim strSubject

    Dim strBody



    Dim strFirstName

    Dim strEmail

    Dim strPhone

    Dim strLastName



    strFirstName = Request.Form("FirstName")

    strEmail = Request.Form("email")

    strPhone = Request.Form("phone")

    strLastName = Request.Form("LastName")





    strFirstName = Replace(strFirstName,"'","''")



    strEmail = Replace(strEmail,"'","''")


    strPhone = Replace(strPhone,"'","''")

    strLastName = Replace(strLastName,"'","''")




    strTo = "peter@cbfx.com"

    strFrom = "info@cbfx.com"

    strSubject = "Spot Analytics Email"



    strBody = "Here's the data: " & vbCrLf & vbCrLf

    strBody = strBody & "FirstName: " & strFirstName & vbCrLf

    strBody = strBody & "Email: " & strEmail & vbCrLf

    strBody = strBody & "Phone: " & strPhone & vbCrLf

    strBody = strBody & "LastName: " & strLastName & vbCrLf



    Set objErrMail= Server.CreateObject("CDO.Message")



    With objErrMail

    .From = strFrom

    .To = strTo

    .Subject = strSubject

    .TextBody = strBody

    '.HTMLBody = strBody

    '.Configuration.Fields.Item ("(URL address blocked: See forum rules)") = 2

    '.Configuration.Fields.Item("(URL address blocked: See forum rules)") = ""

    '.Configuration.Fields.Item("(URL address blocked: See forum rules)") = 25

    .Configuration.Fields.Update

    .Send

    End With






    %>
     
    tatanka, Apr 28, 2008 IP
  2. dgxshiny

    dgxshiny Greenhorn

    Messages:
    65
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    23
    #2
    for each of the required values:


    If strFirstName = "" Then
    'display message
    End If
     
    dgxshiny, Apr 28, 2008 IP