Newbie jquery validate - Validation with ajax submission using plugin
Hello,
I can't get the success message and the submission to happen with ajax:
On myValidation.js I have:
- $('#form-contactos').validate({
- rules: {
- txtResponsavel: "required",
- txtEmail: {
- required: true,
- email: true
- },
- txtMensagem: "required"
- },
- errorPlacement: function(error, element) {
- error.insertAfter(element);
- },
- submitHandler: function(form)
- {
- jQuery(form).ajaxSubmit(
- {
- target: "#resultado",
- success: function()
- {
- $('#resultado').fadeIn('slow')
- }
- });
- }
-
- });
My form on the HTML file is as follow:
- <form id="form-contactos" action="<?php echo filter_var($_SERVER['PHP_SELF'], FILTER_SANITIZE_STRING); ?>" method="post">
- ...
- <div id="resultado" style="background-color: red;">
- <!--hoping to appear some server side message here. :( --></div>
- ...
- <!-- js loading at the end of the body tag.-->
- <script type="text/javascript" src="Js/ValidacaoForm/lib/jquery.js"></script>
- <script type="text/javascript" src="Js/ValidacaoForm/myValidation.js"></script>
- <script type="text/javascript" src="Js/ValidacaoForm/lib/jquery.form.js"></script>
What am I doing wrong?
Thanks in advance,
Márcio