Last active
December 11, 2015 03:39
-
-
Save Godoy/4539660 to your computer and use it in GitHub Desktop.
Sending contact form with coffee + jquery-validate + ajax-post
This file contains 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
$ -> | |
$('#formId').validate | |
rules: { | |
'message[name]': "required" | |
'message[email]': 'required' | |
'message[subject]': 'required' | |
'message[body]': 'required' | |
} | |
submitHandler: (form) -> | |
$.post( | |
$(form).attr('action') | |
$(form).serialize() | |
(data, textStatus, jqXHR) -> | |
if textStatus is 'success' | |
alert 'enviado com sucesso' | |
else | |
alert 'tente novamente mais tarde' | |
) | |
$.validator.messages.required = "Campo obrigatório"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment