Window.location and form submission

Discussion in 'ASP General' started by Lukelrc, May 24, 2004.

  1. Lukelrc

    Lukelrc Guest

    Hi,

    I have a form containing (among other things) date fields for which i
    have a date validation script. What i need to happen is when the user
    presses the submit button the date validation script is run and only
    if the date is correct is the form submited.

    What i have done so far is:

    -Chagned the button type from 'submit' to 'button'
    -put the date validation vbscipt into a sub buttonname_onclick
    -added to the date validation script code that says if the date is
    valid then
    window.location.href = "nextpage.asp"

    it all works fine except that the new record added to the database
    contains no values. It seems that the form does not submit properly
    when i use window.location. Does anyone know to make a form submit
    using window.location, or suggest another workaround?

    Luke
     
    Lukelrc, May 24, 2004
    #1
    1. Advertising

  2. Lukelrc

    Roland Hall Guest

    "Lukelrc" <> wrote in message
    news:...
    : Hi,
    :
    : I have a form containing (among other things) date fields for which i
    : have a date validation script. What i need to happen is when the user
    : presses the submit button the date validation script is run and only
    : if the date is correct is the form submited.
    :
    : What i have done so far is:
    :
    : -Chagned the button type from 'submit' to 'button'
    : -put the date validation vbscipt into a sub buttonname_onclick
    : -added to the date validation script code that says if the date is
    : valid then
    : window.location.href = "nextpage.asp"
    :
    : it all works fine except that the new record added to the database
    : contains no values. It seems that the form does not submit properly
    : when i use window.location. Does anyone know to make a form submit
    : using window.location, or suggest another workaround?

    Hi Luke...

    You need to submit your form. Set your action="nextpage.asp" and if the
    validation passes, then use document.formname.submit();

    Ex.

    <script type="text/javascript">
    function validate() {
    var ename = document.form1.iname;
    if(!ename.value) {
    alert("Please input your email address");
    ename.focus();
    return false;
    } else {
    document.form1.submit();
    return true;
    }
    }
    </script>

    <form id="form1" name="form1" action="nextpage.asp" onsubmit="return
    validate()" />
    <input type="text" id="iname" name="iname" value="" /><br />
    <input type="submit" value="submit" />
    </form>

    FYI... This is not ASP related per se.

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, May 24, 2004
    #2
    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. Jared
    Replies:
    5
    Views:
    215
    Jared
    Jul 10, 2003
  2. Bryan
    Replies:
    1
    Views:
    172
    Murray
    May 25, 2004
  3. saiho.yuen
    Replies:
    3
    Views:
    439
    kaeli
    Sep 14, 2004
  4. ZazuMC

    Form Submission to New Window problem

    ZazuMC, Nov 1, 2007, in forum: Javascript
    Replies:
    1
    Views:
    105
    Evertjan.
    Nov 1, 2007
  5. ZazuMC

    Form Submission to New Window problem

    ZazuMC, Nov 2, 2007, in forum: Javascript
    Replies:
    0
    Views:
    89
    ZazuMC
    Nov 2, 2007
Loading...

Share This Page