What is wrong I want the form and the form validation in the same page

Discussion in 'ASP General' started by karenmiddleol@yahoo.com, Sep 30, 2005.

  1. Guest

    I have a simple form to accept two form fields and display the values
    entered on pressing the submit button. The following is the form I have
    created to accept the two entries and display the form fields on
    pressing the submit form. It does not work can somebody please correct
    the code or provide a simple equivalent code where I can have the form
    and the validation and usage of the form values in the same ASP page.

    Thanks
    Karen

    <html>
    <body>
    <form method="post">
    >From Period : <input type="text" name="FromPeriod">

    <br>
    To Period : <input type="text" name="ToPeriod">
    <input type="submit" value="Submit" action = "Go">
    </form>

    <%
    Dim FromVal, ToVal
    FromVal = Request.Form("FromPeriod")
    ToVal = Request.Form("ToPeriod")
    Response.Write FromVal
    Response.Write ToVal


    If FromVal & ToVal <> ""
    Then
    Response.Write "Valid data entered"
    End If
    %>
    </body>
    </html>
    , Sep 30, 2005
    #1
    1. Advertising

  2. Evertjan. Guest

    wrote on 30 sep 2005 in microsoft.public.inetserver.asp.general:

    > I have a simple form to accept two form fields and display the values
    > entered on pressing the submit button. The following is the form I have
    > created to accept the two entries and display the form fields on
    > pressing the submit form. It does not work can somebody please correct
    > the code or provide a simple equivalent code where I can have the form
    > and the validation and usage of the form values in the same ASP page.
    >
    > Thanks
    > Karen
    >
    > <html>
    > <body>
    > <form method="post">
    >>From Period : <input type="text" name="FromPeriod">

    > <br>
    > To Period : <input type="text" name="ToPeriod">
    > <input type="submit" value="Submit" action = "Go">


    Why action = "Go" ? Has no meaning, imho.

    > </form>
    >
    > <%
    > Dim FromVal, ToVal
    > FromVal = Request.Form("FromPeriod")
    > ToVal = Request.Form("ToPeriod")
    > Response.Write FromVal


    Response.Write FromVal & "<br>"

    > Response.Write ToVal


    Response.Write ToVal & "<br>"

    >
    > If FromVal & ToVal <> ""
    > Then


    The Then must be on the same line as the If

    > Response.Write "Valid data entered"
    > End If
    > %>
    > </body>
    > </html>


    with the Then corrected it works fine here,
    except that

    FromVal & ToVal <> ""

    is true when "one of them is non empty.

    I think you mean:

    If (FromVal <> "") AND (ToVal <> "") Then



    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
    Evertjan., Sep 30, 2005
    #2
    1. Advertising

  3. Steven Burn Guest

    '// Begin pForm.asp
    <html>
    <body>
    <form method="post" action="pForm.asp">
    From Period : <input type="text" name="FromPeriod"><br>
    To Period : <input type="text" name="ToPeriod">
    <input type="submit" value="Submit" action = "Go">
    </form>
    <%
    '// Check the first field only (assumes it is required)
    If Request.Form("FromPeriod") <> "" Then
    Response.Write "From: " & Request.Form("FromPeriod") & "<br>"
    Response.Write "To: " & Request.Form("ToPeriod")
    End If
    %>
    </body>
    </html>

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    <> wrote in message
    news:...
    > I have a simple form to accept two form fields and display the values
    > entered on pressing the submit button. The following is the form I have
    > created to accept the two entries and display the form fields on
    > pressing the submit form. It does not work can somebody please correct
    > the code or provide a simple equivalent code where I can have the form
    > and the validation and usage of the form values in the same ASP page.
    >
    > Thanks
    > Karen
    >
    > <html>
    > <body>
    > <form method="post">
    > >From Period : <input type="text" name="FromPeriod">

    > <br>
    > To Period : <input type="text" name="ToPeriod">
    > <input type="submit" value="Submit" action = "Go">
    > </form>
    >
    > <%
    > Dim FromVal, ToVal
    > FromVal = Request.Form("FromPeriod")
    > ToVal = Request.Form("ToPeriod")
    > Response.Write FromVal
    > Response.Write ToVal
    >
    >
    > If FromVal & ToVal <> ""
    > Then
    > Response.Write "Valid data entered"
    > End If
    > %>
    > </body>
    > </html>
    >
    Steven Burn, Sep 30, 2005
    #3
  4. McKirahan Guest

    <> wrote in message
    news:...
    > I have a simple form to accept two form fields and display the values
    > entered on pressing the submit button. The following is the form I have
    > created to accept the two entries and display the form fields on
    > pressing the submit form. It does not work can somebody please correct
    > the code or provide a simple equivalent code where I can have the form
    > and the validation and usage of the form values in the same ASP page.
    >
    > Thanks
    > Karen


    [snip]

    http://www.aspfaq.com/5003 !
    McKirahan, Sep 30, 2005
    #4
  5. Martin Walke Guest

    HI Karen,

    I don't think you can do what you want this way. You're trying to validate
    data with server side scripting, which is run *before* the page is sent to
    the browser. You need to use client side scripting (js or vb) to validate.

    HTH
    Martin
    <> wrote in message
    news:...
    >I have a simple form to accept two form fields and display the values
    > entered on pressing the submit button. The following is the form I have
    > created to accept the two entries and display the form fields on
    > pressing the submit form. It does not work can somebody please correct
    > the code or provide a simple equivalent code where I can have the form
    > and the validation and usage of the form values in the same ASP page.
    >
    > Thanks
    > Karen
    >
    > <html>
    > <body>
    > <form method="post">
    >>From Period : <input type="text" name="FromPeriod">

    > <br>
    > To Period : <input type="text" name="ToPeriod">
    > <input type="submit" value="Submit" action = "Go">
    > </form>
    >
    > <%
    > Dim FromVal, ToVal
    > FromVal = Request.Form("FromPeriod")
    > ToVal = Request.Form("ToPeriod")
    > Response.Write FromVal
    > Response.Write ToVal
    >
    >
    > If FromVal & ToVal <> ""
    > Then
    > Response.Write "Valid data entered"
    > End If
    > %>
    > </body>
    > </html>
    >
    Martin Walke, Sep 30, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt MC
    Replies:
    2
    Views:
    506
    Thomas 'PointedEars' Lahn
    May 25, 2005
  2. 2 controls on the same page and wrong events fire

    , Jun 2, 2005, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    162
  3. bnp
    Replies:
    4
    Views:
    320
  4. Matt MC
    Replies:
    2
    Views:
    157
    Thomas 'PointedEars' Lahn
    May 25, 2005
  5. pavi
    Replies:
    0
    Views:
    1,332
Loading...

Share This Page