Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- var formulario = document.forms["formContato"];
- $(formulario).bootstrapValidator({
- // To use feedback icons, ensure that you use Bootstrap v3.1.0 or later
- feedbackIcons: {
- valid: 'glyphicon glyphicon-ok',
- invalid: 'glyphicon glyphicon-remove',
- validating: 'glyphicon glyphicon-refresh'
- },
- fields: {
- first_name: {
- validators: {
- stringLength: {
- min: 2,
- },
- notEmpty: {
- message: 'Por favor digite seu nome'
- }
- }
- },
- email: {
- validators: {
- notEmpty: {
- message: 'Por favor digite seu e-mail'
- },
- emailAddress: {
- message: 'Por favor digite um endereço de e-mail válido'
- }
- }
- },
- phone: {
- validators: {
- notEmpty: {
- message: 'Por favor digite seu número de telefone'
- },
- phone: {
- country: 'BR',
- message: 'Por favor digite um número de telefone válido'
- }
- }
- },
- comment: {
- validators: {
- stringLength: {
- min: 10,
- max: 2000,
- message:'A mensagem deve ter de 10 a 2000 caracteres'
- },
- notEmpty: {
- message: 'Por favor digite uma mensagem'
- }
- }
- }
- }
- })
- .on('success.form.bv', function(e) {
- $('#success_message').slideDown({ opacity: "show" }, "slow") // Do something ...
- $('formulario').data('bootstrapValidator').resetForm();
- // Prevent form submission
- e.preventDefault();
- // Get the form instance
- var $form = $(e.target);
- // Get the BootstrapValidator instance
- var bv = $form.data('bootstrapValidator');
- // Use Ajax to submit form data
- console.log(JSON.stringify(form.data));
- $.post($form.attr('action'), $form.serialize(), function(result) {
- console.log(result);
- }, 'json');
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement