Javascript return issue
<p>This problem has just become apparent in some historical code and seems to be an issue relating to IE8 + and FF4 +</p>

<p>I have a js file that validates a contact form, one particular section calls a function to open a new window with some info for the user.  At this point the script seems to ignore my <code>valid = false</code> variable (which is flagged to stop form submission)</p>

<pre><code>function showFormat() {
    var myWindow;
    myWindow = window.open("http://url/page.html","Postcode_Information","location=1,status=1,scrollbars=1,width=640,height=400");
    myWindow.moveTo(50,50);
}
</code></pre>

<p>Above code is causing the issue.  i've tried adding <code>valid=false; return valid;</code> to the end of the function but it is apparently being ignored.  Adding this to the begining of the function means that the validity is correct and the form doesnt submit but obviously my new window doesnt open.</p>

<p><strong>EDIT TO EXPLAIN IN MORE DETAIL</strong></p>

<p>My js file has a series of validation functions (checking username, address, email address validity etc).  A variable is initialised called <code>valid</code> which will always be true unless any user input does not validate, in which case <code>valid = false</code>.</p>

<p>If <code>valid = false</code> then an if statement is run which checks against a number of variables in order to determine which area of the validation has caused the problem and will flag up an appropriate prompt.  Most of these are done via a message box (I inherited this code and am merely trying to get it working) but one prompt opens up a new window.  If any of these prompts are called at all then the form should not be submitted.  </p>

<p>The problem I am having is that when this new window opens (and this is the only prompt causing this issue) the form will still submit.</p>

<p>See code below for an example of when these prompts are called:</p>

<pre><code>if (!valid) {
       if (emailNoAddress == true) {
           alert('You have requested to receive more information by email from other company(ies) but have not provided email address details – Please correct this below');
           highlightEmail();
       }
       else {
           if (contactDetails == false) {
               alert('Please provide your email address details. We will not send you future correspondence and offers by email if you prefer us not to.');
               highlightAddress();
               highlightEmail();
           }
               else {
               if (postcodeGiven == false) {
                            if (dataform.pcode.value == "") {
                                alert('Please enter a valid postcode');
                                }
                            else {
                                showFormat();
                                }           
               }

               else {
                   if (questionsAnswered == false || countryGiven == false) {
                       alert('Please choose an answer from the options provided');
                   }
                   else {
                        //alert(checkstr);
                       alert('Could you please complete the questions missing details');
                   }
               }
           }                            
       }
   }
</code></pre>

<p>So you see, my function can only be called when <code>!valid</code> in which case the form should not submit but as soon as I execute the new window function <code>showformat()</code> it allows the form to be submitted.</p>

<p><strong>EDIT - UPDATE</strong></p>

<p>I've managed to narrow the problem down slightly in  that after the new window opens, no more script is executed (i've tried adding a few alert messages to check the value of <code>valid</code> but they are not shown - I've also tried adding a breakpoint while debugging with Firebug but this is not hit) and the form submits regardless...</p>

<p><strong>EDIT - UPDATE</strong></p>

<p>Beacuse this was a time-critical issue, for the moment I have just put all the text from the pop-up window into an alert and call that instead of the function.  When I have any more time to spend investigatin I will update.</p>
