Skip to content

Instantly share code, notes, and snippets.

@mamiu
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save mamiu/2404cb75feab4ff15487 to your computer and use it in GitHub Desktop.

Select an option

Save mamiu/2404cb75feab4ff15487 to your computer and use it in GitHub Desktop.
callback sample for Lorenz ;)
var contactForm = function(){
var submit = function(email, name, message, callback){
validateForm(email, name, message, function(isValid){
if(isValid){
sendContent(email, name, message, function(succeeded){
if(succeeded){
showInfo(function(){
callback("Message sent successfully");
});
}
});
}
});
}
var validateForm = function(email, name, message, callback){
//check if all required fields are filled and the text is valid (no attacks)
callback(true);
}
var sendContent = function(email, name, message, callback){
//try to send the form content
callback(true);
}
var showInfo(callback){
//open dialog box with success message or replace form with thanks text^^
callback();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment