开发者

jQuery.validate() newbie: it doesn't work for me

开发者 https://www.devze.com 2023-01-17 08:16 出处:网络
Im trying to validate an email field dynamically using开发者_C百科 jquery.validate here. The field i\'m speaking about is \"Email\" (\"Registro\" form).

Im trying to validate an email field dynamically using开发者_C百科 jquery.validate here.

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

Any ideas?


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

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

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


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号