title: Replacing c# function bij Jquery not working without knowing how to troubleshoot
body: <p>I'm trying to replace an ASP.NET (C#) server-sided method by an javascript/Jquery method. I'm fairly new to Jquery but all went well until I began with regular expressions.</p>
  
  <p>my code in ASP.NET C# </p>
  
  <pre><code>if ((Regex.Match(postcode.Trim(), @"^[1-9]\d{3} ?[a-zA-Z]{2}$")).Success)
      {
         return Regex.Replace(postcode.Trim(), @"(^[1-9]\d{3})( ?)([a-zA-Z]{2}$)", "$1$3").ToUpper();
      }
      else
      {
         throw new Exception("Postcode incorrect");
      }
  </code></pre>
  
  <p>in Jquery I'm only focussing to replace for the moment by manually input the right strings.</p>
  
  <p>I've created a function like:</p>
  
  <pre><code>function FormatDutchPostalCode() {
     var postcode = $("#Text1").val();
     postcode = postcode.replace(/(^[1-9]\d{3})( ?)([a-zA-Z]{2}$)/, $1$3);
     $("#Text1").val(postcode);
  }
  </code></pre>
  
  <p>I'm getting the value from the textbox, so far so good. But when replacing it seems the browsers exits the function (tested in IE9 and FF10.0.1)</p>
  
  <p>What I'm i doing wrong and is it possible to troubleshoot Jquery/Javascript. I've seen firebug could set breakpoints but I can't find if (and if so which) errors occur.</p>