Skip to content

Instantly share code, notes, and snippets.

@Godoy
Last active December 11, 2015 03:39
Show Gist options
  • Save Godoy/4539660 to your computer and use it in GitHub Desktop.
Save Godoy/4539660 to your computer and use it in GitHub Desktop.
Sending contact form with coffee + jquery-validate + ajax-post
$ ->
$('#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