Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Popup window on submit form

    I am VERY new to javacsript. I am validating a form onsubmit and then i want the new window to popup in a new winow... This is what i have:

    <script language="JavaScript">
    function validate(returnvalue)
    {
    //Validation Control Center
    //Use validateNotEmpty(fieldname,errormessage) to check if the field is empty
    //Use validateEMailCheck(fieldname,errormessage) to check if the email address is valid
    //These must go inside if statement
    var anError
    if (validateNotEmpty(document.MailingList.Email.value,"You must enter your e-mail address")==false)
    {
    anError=true
    }
    else
    {
    if (validateEMailCheck(document.MailingList.Email.value,"You must enter a valid e-mail address for yourself")==false)
    {
    anError=true
    }
    else
    {
    if(document.MailingList.SportsMailing.checked==false && document.MailingList.GamingMailing.checked==false)
    {
    alert("You must choose at least one topic");anError=true;
    }
    }
    }
    if (anError==true)
    {
    return false;
    }
    else
    {
    open.window(' ','Mailing',"width=452,height=325,scrollbars=no")
    return true;
    }
    }

    But i can not get the action="" of the form to make it in a new window... is there a way of doing it!?

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,040
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Code:
    <script type="text/javascript">
    function validate(objForm, returnvalue)
    {
       //Validation Control Center
       //Use validateNotEmpty(fieldname,errormessage) to check if the field is empty
       //Use validateEMailCheck(fieldname,errormessage) to check if the email address is valid
       //These must go inside if statement
       var anError
       if (validateNotEmpty(objForm.Email.value,"You must enter your e-mail address")==false)
       {
          anError=true;
       }
       else if (validateEMailCheck(objForm.Email.value,"You must enter a valid e-mail address for yourself")==false)
       {
          anError=true
       }
       else if(objForm.SportsMailing.checked==false && objForm.GamingMailing.checked==false)
       {
          alert("You must choose at least one topic");
          anError=true;
       }
       if (anError==true)
       {
          return false;
       }
       else
       {
          var w = window.open('', objForm.target, "width=452,height=325,scrollbars=no");
          w.focus();
          return true;
       }
    }
    </script>
    ...
    <form name="MailingList" action="process.php" target="MailingListPopup" onsubmit="return validate(this, returnvalue)">
    ...
    <input type="submit" value="Submit" />
    </form>
    I don't know the use of returnvalue argument in the validate() function. You don't use it inside the function.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •