0

hello boss! can any one help me to do this. :S

my .ajaxForm() code is working but i want to have validation first for the field before ajax start to work.

here's my code:
my script:

    <script> 
        $(document).ready(function() 
            { 

            $('#myForm').validate({ 
                        rules: {
                            newsletter: {
                                required: true,
                                email: true}
                        }
            });

            $('#myForm').ajaxForm(function() {
                alert("Thank you!"); 
            }); 

        }); 
    </script> 

my form:

     <form id="myForm" action="savenewsletter.php" method="post"> 
        Name: <input type="text" name="newsletter" /> 
        <input type="submit" value="Submit Comment" /> 
     </form>

my php

mysql_query("INSERT INTO newsletter_tb (newsLetterEmail) VALUES ('$_POST[newsletter]')");
4
Contributors
3
Replies
24
Views
3 Years
Discussion Span
Last Post by pixelsoul
0

Hi, this looks like jquery.form.js and the jquery validation plugin. This could be because the ajaxForm method is getting executed first. Does re-ordering your links to the plugins help? so you have your jquery library first, then your validation plugin and then your jquery.form.js?

0

If you're using the ajaxForm plugin that I think you're using (http://malsup.com/jquery/form/) this has built in validation already. But if you want to use this other validation, you can do use the 'beforeSubmit' callback and then call the other validation plugin. That is if you are indeed using the mentioned plugin.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.