Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Laravel with Bootstrap open modal or popup automatically

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 7.30k
    Comment on it

    Hi Readers,

    If you are using Bootstrap in your application you should use modal to show popups in your web application. Modal is a very nice feature provided by the Bootstrap to show nice and beautiful popups which can be easily modifiable. I recently used them in my recent project.

    I had a form in my modal which need to be filled by the end user. I had implemented both client and server side validation on it. If there is any error from the client side it is shown immediately but if the error is from the server side I had a problem showing it. The reason behind it was that on successful submit of the form the webpage use to get reloaded and the modal close out.

    So, to open modal(popup) automatically we check for any error from the server side validation and thus open modal if found any. To make if possible you can use the following jQuery code.


    <div class="clearfix error2 col-md-12" id="errorMessageEmailShareModal">
        @if (count($errors-&gt;emailShare) &gt; 0)
        <script type="text/javascript">
            $(window).load(function() {
        <div class="alert alert-danger">
            <strong>Whoops!</strong> There were some problems with your input.<br><br>
                @foreach ($errors-&gt;emailShare-&gt;all() as $error)
                <li>{{ $error }}</li>

    HTML Syntax:-

    <div class="modal fade" id="emailShare" tabindex="1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: