Redirect back to modal

i have a form in modal and after submission i validate the data , how can i redirect back to the modal if validation fails...? Please help..!!!!



61.2k

Because i have no idea what packages you are using, here is an bootstrap example that should do the trick

$(document).ready(function(){
    var $modal = $("#myModal");
    if (document.location.hash === "invalidRegisterForm"){
        $modal.modal("open"); // check this cuz i have forgotten how exactly was the bootstrap API
    }
});

in the controller you need to redirect to something like this

www.aaaaa.com/user/register#invalidRegisterForm


61.2k
edited Apr '17

or another was is in volt or whatever

if false === form.isValid() {
    <script type="text/javascript>
        var modal .. modal.open()
    </script>
}

but putting form in modals is one of the stupidiest ideas I have ever came up with :D