Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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
modal("frage-2","xarelto20mg","{{ __('xarelto::p20.error_message') }}", false);
function modal(frage,antwort,error_message, clicked)
// 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)
// 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>');
closeOnBackgroundClick : false,
closed : function(){ // if the user close the modal window set var clicked to true and trigger this function again
clicked = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment