Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Inform a user about his wrong answer with foundation modal window and pass to next page while closing the modal
/*
usage: request the function modal with following parameters
- input name
- correct answer
- error message
- last parameter is a swich needs to be false
<script>
$(document).ready(function()
{
modal("frage-2","xarelto20mg","{{ __('xarelto::p20.error_message') }}", false);
})
</script>
*/
function modal(frage,antwort,error_message, clicked)
{
$(".nice").on("submit",function(e)
{
// if user has close the modal window pass to next page
if( clicked === true)
{
return true;
}
// if user chose the wrong answer stop the submit event and raise an error message in a modal window
if ($("input[name="+frage+"]:checked").val() != antwort)
{
e.preventDefault();
// add the modal window to the page
$(this).append('<div id="myModal" class="reveal-modal xlarge"><p>'+error_message+'</p> <a class="close-reveal-modal">&#215;</a></div>');
$("#myModal").reveal(
{
closeOnBackgroundClick : false,
closed : function(){ // if the user close the modal window set var clicked to true and trigger this function again
clicked = true;
$(".nice").submit();
}
}
);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.