Modal mit Formular

CreativPur

Erfahrenes Mitglied
Hi,
ich steh mal wieder auf dem Schlauch.

Ich habe ein Modal-Fenster, wo ich ein kleines Domain-Check Formular mit einem Submut-Button habe.
Beim betätigen des Submit-Button wird das Resultat der Anfrage ausgegeben.

Leider schließt dabei auch das Modal-Fenster.

Wie kann ich das Schließen des Fensters deaktivieren, und es nur schließen, wenn ich auf den lose-Button klicke ?

Der Modal-Button
HTML:
<a href="#" data-toggle="modal" data-target="#myModal">Domain-Check für Ihre Internetpräsentation</a>

das Modal mit Formular
PHP:
<!-- Domain-Check -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"  aria-hidden="true">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Modal title</h4>
              </div>
              <div class="modal-body">
                
                <form action="#" method="post">
                    <table width="100%" border="0" align="center">
                      <tr>
                        <td colspan="3" align="center"><span style="font-size:12px; color:blue;">
                            Wählen Sie Ihre Wunsch-Domain</span>&nbsp;&nbsp;<span style="font-size:12px; color:red;">(ohne http://www.)</span><hr />
                        </td>
                        </tr>
                      <tr>
                        <td width="60"><input type="text" name="domain_name" class="form-control" placeholder="z.B. Creativpur" /></td>
                        <td width="35">
                            <select name="ubhbz" class="form-control" >
                            <option value=".de">.de</option>
                            <option value=".com">.com</option>
                            <option value=".info">.info</option>
                            <option value=".net">.net</option>
                            <option value=".org">.org</option>
                            </select>
                        </td>
                        <td width="15" align="center">
                            <button type="submit" name="check"   id="myFormSubmit" class="btn btn-success btn-xs" style="height:21px; font-size:13px;">prüfen</button>
                        </td>
                      </tr>
                    </form>
                    <?php
                    echo '<tr align="center">
                        <td colspan="3">';
                        
                        if(isset($_POST['check'])) {
                    
                     if (!empty($_POST['domain_name'])){
                     $name_domain = trim($_POST['domain_name']).$_POST['ubhbz'];
                     $response = @dns_get_record($name_domain, DNS_ALL);
                     if(empty($response)){
                     echo "<hr /><span style='font-size:13px;'><span style='color:blue;'>www.$name_domain</span> ist noch <span style='color:green;'>frei</span>.</span>";
                    
                     }else{
                     echo "<hr /><span style='font-size:13px;'><span style='color:blue;'>www.$name_domain</span> ist schon <span style='color:red;'>vergeben</span>.</span>";
                     }
                     }
                     else {
                     echo "<hr /><p style='color:red;font-size:13px;'>Geben Sie bitte einen Domain-Namen ein.</p>";
                     }
                    }
                    echo '   
                        </td>
                        </tr>
                    </table>';
                    
                    ?>
                </table>
                
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">schließen</button>
              </div>
            </div>
          </div>
        </div>
 
PHP:
 <!-- Domain-Check -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"  aria-hidden="true">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Modal title</h4>
              </div>
              <div class="modal-body">
              
              
                <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
                <script src="http://malsup.github.com/jquery.form.js"></script>
                
                <script>
                        // wait for the DOM to be loaded
                        $(document).ready(function() {
                            // bind 'myForm' and provide a simple callback function
                            $('#myForm').ajaxForm(function() {
                                alert("Thank you for your comment!");
                            });
                        });
                    </script>
                
                <form action="#"  id="myForm" method="post">
                    <table width="100%" border="0" align="center">
                      <tr>
                        <td colspan="3" align="center"><span style="font-size:12px; color:blue;">
                            Wählen Sie Ihre Wunsch-Domain</span>&nbsp;&nbsp;<span style="font-size:12px; color:red;">(ohne http://www.)</span><hr />
                        </td>
                        </tr>
                      <tr>
                        <td width="60"><input type="text" name="domain_name" class="form-control" placeholder="z.B. Creativpur" /></td>
                        <td width="35">
                            <select name="ubhbz" class="form-control" >
                            <option value=".de">.de</option>
                            <option value=".com">.com</option>
                            <option value=".info">.info</option>
                            <option value=".net">.net</option>
                            <option value=".org">.org</option>
                            </select>
                        </td>
                        <td width="15" align="center">
                            <button type="submit" name="check"   id="myFormSubmit" class="btn btn-success btn-xs" style="height:21px; font-size:13px;">prüfen</button>
                        </td>
                      </tr>
                    </form>
                    <?php
                    echo '<tr align="center">
                        <td colspan="3">';
                        
                        if(isset($_POST['check'])) {
                    
                     if (!empty($_POST['domain_name'])){
                     $name_domain = trim($_POST['domain_name']).$_POST['ubhbz'];
                     $response = @dns_get_record($name_domain, DNS_ALL);
                     if(empty($response)){
                     echo "<hr /><span style='font-size:13px;'><span style='color:blue;'>www.$name_domain</span> ist noch <span style='color:green;'>frei</span>.</span>";
                    
                     }else{
                     echo "<hr /><span style='font-size:13px;'><span style='color:blue;'>www.$name_domain</span> ist schon <span style='color:red;'>vergeben</span>.</span>";
                     }
                     }
                     else {
                     echo "<hr /><p style='color:red;font-size:13px;'>Geben Sie bitte einen Domain-Namen ein.</p>";
                     }
                    }
                    echo '   
                        </td>
                        </tr>
                    </table>';
                    
                    ?>
                </table>
                
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">schließen</button>
              </div>
            </div>
          </div>
        </div>
 
Habe ich getestet und bei mir funktioniert es einwandfrei, alert ohne Neuladen der Seite.
Tritt die ID "myForm" u. U. mehrfach auf?
Hast Du u. U. noch einen onsubmit-Handler?
Gibt die Console etwas aus?
Wenn das alles nicht weiter hilft: Hast Du die Seite online und kannst die URL posten?
 
Zurück