views:

53

answers:

2

HI,

Im trying to validate an email field dinamically using jquery.validate here.

The field i'm speaking about is "Email" ("Registro" form).

any idea?

Regards

Javi

+6  A: 

Your script order is reversed, include juery before any plugins, like this:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt; 
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"&gt;&lt;/script&gt; 

Also since I don't see any conflicts, I'd go ahead and move to jQuery 1.4 to get the latest benefits.

Nick Craver
I second this. If you're ever using a script that requires jQuery (or any other library for that matter), ensure the library is loaded before the script so it has access to it.
Bradley Herman
Thanks, but it didn't work. I tried also with 1.4 but nothing...
A: 

I failed inside the rule..This works ok:

<script type="text/javascript">

$.validator.setDefaults({

    submitHandler: function() { alert("submitted!"); }

});



$().ready(function() {


    // validate signup form on keyup and submit

    $("#jander").validate({

        rules: {

            'sfApplyApply[email]': {

                required: true,

                email: true

            }

        },

        messages: {

            'sfApplyApply[email]': "Please enter an email",



        }

    });





});

</script>