Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function()
- {
- $("#botao").click(function()
- {
- $("#forma").validate({
- rules:{
- nome:{
- required: true,
- minlength: 3
- },
- email:{
- required: true,
- email: true
- },
- cpf:{
- required: true,
- minlength: 14
- },
- data_nasc:{
- required: true,
- minlength: 10
- },
- sexo:{
- required: true
- }
- },
- messages:{
- nome:{
- required: "O campo nome é obrigatório.",
- minlength: "Mínimo de 3 caracteres."
- },
- email:{
- required: "O campo email é obrigatório.",
- email: "Email inválido. Insira corretamente."
- },
- cpf:{
- required: "O campo CPF/CNPJ é obrigatório.",
- minlength: "Número inválido. Insira corretamente."
- },
- data_nasc:{
- required: "O campo data de nascimento é obrigatório.",
- minlength: "Data inválida. Insira corretamente."
- },
- sexo:{
- required: "É necessário escolher uma opção."
- }
- }
- });
- if($('#forma').validate().form() == true){
- $('#loading').css({'display': 'inline'});
- $.ajax({
- url: './php/main.php',
- type: 'POST',
- async: true,
- data: {
- nome: $('#nome').val(),
- cpf: $('#cpf').val(),
- email: $('#email').val(),
- data_nasc: $('#data_nasc').val(),
- sexo: $("[name='sexo']:checked").val()
- },
- success: function(text) {
- $('#testeajax').text('');
- //$(text).appendTo('#testeajax');
- $('#loading').css({'display': 'none'});
- $('#testeajax').html(text);
- /*if(text == 's')
- {
- alert('Cliente cadastrado com sucesso!\nUsuário:'+$('#nome').val()+'\nSenha: enc123');
- }
- else
- {
- alert('Problema ao cadastrar o cliente');
- }*/
- },
- error: function() {
- $('#testeajax').text('Erro no Ajax!');
- }
- /*complete: function()
- {
- $('#loading').css({'display': 'none'});
- }*/
- });
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement