Bootstrap: Modal closing while inputs not filled
<p>I'm making modal using Bootstrap. I need to prevent modal closing while required inputs are not filled or requirements for inputs are not met.
And how can i realise the requirements for the inputs? Something like <code>RegExp</code>? </p>

<pre><code>&lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"&gt;
    &lt;div class="modal-dialog" role="document"&gt;
        &lt;div class="modal-content"&gt;
            &lt;div class="modal-header"&gt;
                &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                    &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
                &lt;/button&gt;
                &lt;h4 class="modal-title" id="myModalLabel"&gt;Adding a user&lt;/h4&gt;
            &lt;/div&gt;
            &lt;form name="userAdding"&gt;
                &lt;div class="modal-body"&gt;
                    &lt;input type="text" required placeholder="Name" id="inputName"&gt;
                    &lt;br&gt;
                    &lt;input type="text" required placeholder="Username" id="inputUsername"&gt;
                    &lt;br&gt;
                    &lt;input type="email" required placeholder="Email" id="inputEmail"&gt;
                    &lt;br&gt;
                    &lt;input type="text" placeholder="Street" id="inputStreet"&gt;
                    &lt;br&gt;
                    &lt;input type="text" placeholder="Suite" id="inputSuite"&gt;
                    &lt;br&gt;
                    &lt;input type="text" placeholder="City" id="inputCity"&gt;
                    &lt;br&gt;
                    &lt;input type="number" placeholder="Zipcode" id="inputZipcode"&gt;
                    &lt;br&gt;
                    &lt;input type="number" placeholder="Lat" id="inputLat"&gt;
                    &lt;br&gt;
                    &lt;input type="number" placeholder="Lng" id="inputLng"&gt;
                    &lt;br&gt;
                    &lt;input type="number" placeholder="Phone" id="inputPhone"&gt;
                    &lt;br&gt;
                    &lt;input type="text" placeholder="Website" id="inputWebsite"&gt;
                    &lt;br&gt;
                    &lt;input type="text" required placeholder="Companyname" id="inputCompname"&gt;
                    &lt;br&gt;
                    &lt;input type="text" placeholder="Catchphrase" id="inputCatchphrase"&gt;
                    &lt;br&gt;
                    &lt;input type="text" placeholder="bs" id="inputBs"&gt;
                 &lt;/div&gt;
            &lt;/form&gt;
            &lt;div class="modal-footer"&gt;
                &lt;button type="button" class="btn btn-primary" data-dismiss="modal" onclick="addUser()"&gt;Submit&lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>