Skip to content

Instantly share code, notes, and snippets.

@pabloprogramador
Last active December 28, 2015 14:09
Show Gist options
  • Select an option

  • Save pabloprogramador/7513047 to your computer and use it in GitHub Desktop.

Select an option

Save pabloprogramador/7513047 to your computer and use it in GitHub Desktop.
ajax
<form id="formAmigo" action="" method="post">
<input name="seu_nome" type="text" data-required/>
<input name="seu_email" type="text" data-required data-pattern="^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$"/>
</form>
<script>
$(document).ready(function(){
$('#formAmigo').validate({
sendForm: false,
onKeyup: true,
valid: function() {
$(this).fadeOut('slow');
$.ajax({
url:'{{ url:base }}loja/ajax_amigo/',
type:'POST',
data:$(this).serializeArray(),
success:function(data, status, xhr){
$('#mensagemAmigo').fadeIn('slow');
}
});
},
eachInvalidField : function() {
$(this).css('background', '#F1D7D7');
},
eachValidField : function() {
$(this).css('background', '#EDFFED');
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment