title: LiveCycle Javascript Function ReferenceError
body: <p>I can't figure out what I am doing wrong with this function for livecycle checking the email address. Livecycle console returns an error of "ReferenceError: emailAddress not defined" even though the function will fire the alert or xfa.host.messageBox. Can you tell me why the global variable emailAddress can't be defined after running through this function. Thanks for your time.</p>
  
  <pre><code>function fxemailverification(emailAddress) {
  
      var r = new RegExp("^[A-Za-z0-9_\\-\\.]+\\@test.com");
  
      // Test the rawValue of the current object to see if it matches the new RegExp
      var result = r.test(emailAddress); 
  
      if (result == false) {
          var emailAddress = "";
          alert("You have entered an invalid Email address. \nAll email addresses must end in '@test.com'.", "Email Verification", 4, 0);
      }
      return emailAddress;
  };
  
  textfield1.rawValue = fxemailverification(emailAddress);
  </code></pre>