[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

jQuery Question

Hello,

I'm using jquery with the form and validation plugins. I have this:

<script type="text/javascript">
        $(document).ready(function() {
                $("#autoSumForm").validate({
                        rules: {
                                p1001: {number: true},
                                p1002: {number: true}
                        },
                        messages: {
                                p1001: "",
                                p1002: ""
                        }
                });

                $('#autoSumForm').ajaxForm(function() {
                        alert("Time submitted.");
                });
        });
</script>

The validation and the form submit both work, but the form submits
even if not valid. How do I combine the two?

Thanks.
0
swilschutz
Asked:
swilschutz
1 Solution
 
Terry_focusCommented:
Here you can use ajaxSubmit instead of ajaxForm
<script type="text/javascript">
        $(document).ready(function() {
                $("#autoSumForm").validate({
                        rules: {
                                p1001: {number: true},
                                p1002: {number: true}
                        },
                        messages: {
                                p1001: "",
                                p1002: ""
                        },
                        submitHandler: function(form) {
   	                    $(form).ajaxSubmit(function(){alert("Time submitted.");});
                        }
                });

        });
</script>

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now