javascript form validation - form action to another asp page

Discussion in 'ASP General' started by iam247@gmail.com, Aug 7, 2005.

  1. Guest

    Hi

    In my prototype asp page (with no javascript and no password
    validation, I have a registration form with the following action:

    <form name="form" method="post" action="RegDetails.asp">

    This works fine, the form details are collected by RegDetails.asp

    I am attempting to include javascript server side validation for the
    pasword, which obviously requires password and password2 fields (to be
    verified). I have used the script available at:

    http://javascript.internet.com/forms/val-pass.html

    It works fine in a new blank page with the form action:

    <form name=myForm onSubmit="return validatePwd()">

    The final stage in this javascript demo form displays an alert box:

    else {
    alert('Nice job.');
    return true;


    When I change the first line of my original form to:

    <form name=myForm onSubmit="return validatePwd()">

    how do I get my original action of - action="RegDetails.asp" instead
    of this alert box?

    Thanks ColinK
     
    , Aug 7, 2005
    #1
    1. Advertising

  2. Guest

    Hi Dave

    Thanks for your interest.

    My original form, without validation had the following original action:

    <form name="myform" method="post" action="RegDetails.asp">

    I modified my form from the one I got at:

    http://javascript.internet.com/forms/val-pass.html

    <form name=myForm onSubmit="return validatePwd()">

    So the action of the form now passes Pasword and Password2 to the
    javascript for validation - BUT how do I then get my form fields to
    pass to my other page RegDetails.asp ?

    Thanks ColinK
     
    , Aug 7, 2005
    #2
    1. Advertising

  3. Guest

    Hi Dave

    Thanks for your interest.

    My original form, without validation had the following action:

    <form name="myform" method="post" action="RegDetails.asp">

    I modified my form from the one I got at:

    http://javascript.internet.com/forms/val-pass.html

    <form name=myForm onSubmit="return validatePwd()">

    The form now passes Password and Password2 to the
    javascript for validation - BUT how do I then get my form fields to
    pass to my other page RegDetails.asp ? ie to also do the following
    action:

    action="RegDetails.asp"
     
    , Aug 7, 2005
    #3
  4. Guest

    Hi

    >If you do not quote, I will not respond further


    Thanks for your help.

    The quote was copied manually.

    Using google how do I reply and include the original message?

    Thanks Colin
     
    , Aug 7, 2005
    #4
  5. Guest

    Hi Dave

    Your message to me - I do not know how to copy with >

    Truth is, a FORM element is allowed to have both an ACTION attribute
    and an
    ONSUBMIT attribute at the same time. I have no idea why you took the
    action
    out in the first place. Put it back. Returning a value of [false] will
    prevent the form submission. Example:

    <form action="xxx.asp" onsubmit="return validate(this)">
    <input name="favoriteIceCream">
    </form>
    function validate(f) {
    if (f.favoriteIceCream.value == "") return false
    return true
    }

    I do not have enough experience to use the above apart from
    understanding

    >a FORM element is allowed to have both an ACTION attribute and an

    ONSUBMIT attribute at the same time.

    But I cannot implement both at the same time

    When I use either of the 2 form headers below, the passwords are
    verified but the form fields are sent back to the same form as a
    querystring added to the form page url - the form reopens blank.

    >From what you are saying, the second form header should post the form

    fields to register.asp

    <form name=myForm onSubmit="return validatePwd()">

    <form name=myform method=post onSubmit="return validatePwd()"
    action=RegDetails.asp>

    My original form without the javascript has this header and posts OK.

    <form name=form method=post action=RegDetails.asp>

    Just as a reminder the javascript came from:
    http://javascript.internet.com/forms/val-pass.html

    Any further help would be appreciated

    ColinK
     
    , Aug 7, 2005
    #5
  6. Guest

    Hi Dave
    Thanks for your continued interest.

    As per my previous post I still do not know how to copy with > - so the
    follwoing is manually copied:
    >

    Truth is, a FORM element is allowed to have both an ACTION attribute
    and an
    ONSUBMIT attribute at the same time. I have no idea why you took the
    action
    out in the first place. Put it back. Returning a value of [false] will
    prevent the form submission. Example:

    <form action="xxx.asp" onsubmit="return validate(this)">
    <input name="favoriteIceCream">
    </form>
    function validate(f) {
    if (f.favoriteIceCream.value == "") return false
    return true
    }

    Hopefully the following will more accurately clarify the problem.
    If I copy all of the script from:
    <form name=myform method=post onSubmit="return validatePwd()"
    action=RegDetails.asp>

    Into a new page, the validation works fine. If the 2 passwords match
    the final result is:
    1. The "nice Job" alert pops up
    2. A blank form reloads with the original url + the querystring of
    Password 1& 2
    eg
    http://localhost/gc7/www/pass.asp?password=123456&password2=123456

    If I remove the complete line for the last alert
    alert('Nice job.');

    Result 1 above obviously does not work but result 2 does.

    The Problem

    If I change the form header from the original to any of the 2
    alternatives - shown at bottom (from my own original non validating
    page) The form does not validate the passwords but post to
    RegDetails.asp - same as my own original.

    I want to be able to validate and post - but I can't do both

    Thanks ColinK
    ORIGINAL
    <form name=myForm onSubmit="return validatePwd()">
    ALTERNATIVE1
    <form name="myform" method="post" onSubmit="return validatePwd()"
    action="RegDetails.asp">
    ALTERNATIVE2
    <form name=myform method=post onSubmit="return validatePwd()"
    action=RegDetails.asp>

    Note I have 2 alternatives as the javascript did not seem to like the
    "" in some parts of my original page.
     
    , Aug 8, 2005
    #6
  7. Guest

    Hi Dave

    I still do not know how to copy the original post - so the following is
    manually copied

    Truth is, a FORM element is allowed to have both an ACTION attribute
    and an
    ONSUBMIT attribute at the same time. I have no idea why you took the
    action
    out in the first place. Put it back. Returning a value of [false] will
    prevent the form submission. Example:

    <form action="xxx.asp" onsubmit="return validate(this)">
    <input name="favoriteIceCream">
    </form>
    function validate(f) {
    if (f.favoriteIceCream.value == "") return false
    return true
    }

    Hopefully the following will more accurately clarify the problem.
    If I copy all of the script from:
    http://javascript.internet.com/forms/val-pass.html

    Into a new page, the validation works fine. If the 2 passwords match
    the final result is:
    1. The "nice Job" alert pops up
    2. A blank form reloads with the original url + the querystring of
    Password 1& 2
    eg
    http://localhost/gc7/www/pass.asp?password=123456&password2=123456

    If I remove the complete line for the last alert
    alert('Nice job.');

    Result 1 above obviously does not work but result 2 does.

    The Problem

    If I change the form header from the original to any of the 2
    alternatives - shown at bottom (from my own original non validating
    page) The form does not validate the passwords but post to
    RegDetails.asp - same as my own original.

    I want to be able to validate and post - but I can't do both

    Thanks ColinK
    ORIGINAL
    <form name=myForm onSubmit="return validatePwd()">
    ALTERNATIVE1
    <form name="myform" method="post" onSubmit="return validatePwd()"
    action="RegDetails.asp">
    ALTERNATIVE2
    <form name=myform method=post onSubmit="return validatePwd()"
    action=RegDetails.asp>

    Note I have 2 alternatives as the javascript did not seem to like the
    "" in some parts of my original page.
     
    , Aug 8, 2005
    #7
  8. Guest

    Hi Dave

    I was going to write a post that suggested you were an "too arrogont
    with your responses" but then I thought "maybe Dave is a leading light
    in in this newsgroup - I better be sure before I write too much"

    I also thought, "maybe it was the way I posed the question"

    Then I did some research into previous posts - over a few years.

    You are too arrogont with your responses - frequently

    I did get polite and helpful solutions elsewhere.

    In future, if you see a post from me just ignore it.

    Thanks ColinK
     
    , Aug 20, 2005
    #8
    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. Joe Bloggs
    Replies:
    1
    Views:
    890
    Sudsy
    Aug 3, 2003
  2. Behzad
    Replies:
    6
    Views:
    718
    Juan T. Llibre
    Apr 27, 2007
  3. vyshu
    Replies:
    1
    Views:
    2,610
    Richard Senior
    Apr 27, 2007
  4. John
    Replies:
    0
    Views:
    957
  5. Replies:
    2
    Views:
    236
Loading...

Share This Page