Last active
August 29, 2015 14:15
-
-
Save mamiu/2404cb75feab4ff15487 to your computer and use it in GitHub Desktop.
callback sample for Lorenz ;)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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