Jquery验证插件 - TypeError:$(...)。validate不是函数 [英] Jquery validation plugin - TypeError: $(...).validate is not a function

查看:154
本文介绍了Jquery验证插件 - TypeError:$(...)。validate不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本抛出错误:


TypeError:jQuery.validator未定义additional-methods.js:20
TypeError: $(...)。validate不是函数index.php:115

TypeError: jQuery.validator is undefined additional-methods.js:20 TypeError: $(...).validate is not a function index.php:115

可能我在jQuery代码中有错误。

Probably, I have mistake in jQuery code.

<head>
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script src="http://jquery.bassistance.de/validate/additional-methods.js"></script>
</head>
<body>
            <form id="registerForm" method="post" action="logrej.php">
            <input name="login" type="text"/>
            <input name="nick" type="text"/>
            <input type="password" id="passw" name="password"/>
            <input type="password" name="retype" />
            <input type="submit" value="Zarejestruj!" />
            </form>
            <script>

                $("#registerForm").validate({
                    rules: {
                        login: {
                            required:true,
                            rangelenght: [4,20],
                            remote:"look.php"
                        },
                        nick : {
                            required:true,
                            rangelenght:[4,20],
                            remote:"look.php"
                        },
                        password: {
                            required:true,
                            rangelenght:[4.20]
                        },
                        retype: {
                            required:true,
                            equalTo:"#passw"
                        }
                    },
                    messages:{
                        login:{
                            required:"To pole jest wymagane!"
                        }
                    }
                })

            </script>


推荐答案

您没有加载验证插件。您需要:

You're not loading the validation plugin. You need:

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>

将它放在加载其他方法的行之前。

Put this before the line that loads the additional methods.

此外,您还应该从CDN获取其他方法,而不是jquery.bassistance.de。

Also, you should get the additional methods from the CDN as well, rather than jquery.bassistance.de.

其他错误:

[4.20]

应该

[4,20]

rangelenght:

应为:

rangelength:

这篇关于Jquery验证插件 - TypeError:$(...)。validate不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆