regex breaks modal and accordion inside modal dialog

regex breaks modal and accordion inside modal dialog

Hi folks,
I'm experiencing two problems. 1) my accordion wont display in my dialog modal window and 2) certain regex expressions break the dialog  modal box resulting in no dialog.

I have a php/mysql/jquery page (viewContacts.php) that when you click on a button it brings up a "loading message, displays a previously hidden div, and then POSTs a form into that div. This seems to work ok
$(document).ready(function() {
 $('a.addContacts').click(function(e) {
   e.preventDefault();
    $("#loader").fadeIn();
    $.ajax({
      type: "POST",
      url: "addContacts.php",
      cache: false,
      dataType: "html",
      beforeSend: function() { $("#dialogdiv").show(); },
      success: function(msg) { $("#dialogdiv").html(msg);     }
     });
   });














The addContacts.php contains an accordion inside a dialog modal:
$(document).ready(function() {
 $("#accordion").accordion({
  collapsible: true,
  autoHeight: false,
  fillSpace: false,
  active: false
 });
 $('#dialog').dialog();









});


</script>
</head>

<div id="dialog" title="Add Contact">
 <div id="dialogloader" class="loader">Adding Contact Record....</div>
  <form method="post" name="add_contact" id="add_contact" action= "<?
php echo $editFormAction; ?>">
  <p id="validateTips"><center><i>Please note all three sections must
be completed</i></center></p>
   <div id="accordion">
    <h3><a href="#">Contact Name Details</a></h3>
    <div><form> .......</div>
    <h3><a href="#">Contact Phone Details</a></h3>
    <div><form> .......</div>
    <h3><a href="#">Contact Address Details</a></h3>
    <div><form> .......</div>
   </div>
 </div>
</div>
















The accordion contains a form which does some rudimentary checking to ensure that the details added are correct. But two of the Regexp's appear to break the modal window:

$("#dialog").dialog({
 bgiframe:      true,
 autoOpen:      true,
 height:                760,
 width:                 1150,
 modal:                 true,
 buttons: {
  'Add Contact': function() {
   $("#dialogloader").show();
   var bValid = true;
   bValid = bValid && checkLength(cntct_email,"eMail Address",1,50);
   bValid = bValid && checkRegexp(cntct_email,/^[\w-]+(?:\.[\w-]+)*@(?: [\w-]+\.)+[a-zA-Z]{2,7}$/,"Invalid eMail");
// breaks bValid = bValid && checkRegexp(cntct_street,/^([a-zA-Z /-.])+ $/i,"Street allows only a-z, A-Z");
// breaks bValid = bValid && checkRegexp(cntct_suburb,/^([a-zA-Z ])+$/i,"Suburb allows only a-z, A-Z");
   bValid = bValid && checkRegexp(cntct_city,/^([a-zA-Z ])+$/i,"City allows only a-z, A-Z");
   bValid = bValid && checkRegexp(cntct_postcode,/^([0-9a-zA-Z ])+$/i,"Postcode allows only 0-9,a-Z,A-Z");
   },
Cancel: function() {
 $("#dialog").remove();
 $(this).dialog('close');
  }
 }






















};


Simply put, the modal window no longer appears.

Secondly With these two lines commented out, I can load the modal window up by accessing the addContacts.php form directly in the browser and the accordion displays correctly, however when I load it
up from the viewContacts.php file, I loose the modal dialog and end up with no Accordion effect.


1) Is there something about the us of Regular expressions which is causing the modal to fail

2) Is the modal window a problem to do with delegation or something? Or is there a limitation when it comes to displaying an accordion within a modal?

Would really appreciate some thoughts from people on this as it has me
stumped. Its probably something really simple and obvious.

Thanks in advance