jQuery验证中的问题 [英] Problem in validation of jquery
问题描述
大家好
在此先感谢
问题是我提到的代码在具有依赖项的html文件中可以正常工作
Hi All
Thanks in Advance
The problem the code which i am mentioned working fine in the html file with dependencies
$("#formid").validate({
rules: {
cnName : {
required :true,
minlength: 3
}
},
messages : {
cnName: {
required: "Please enter a name",
minlength: "must 3 elements"
}
}
});
但是当涉及到该应用程序时,在我的应用程序中,我们提到了.js文件中的javascript并像下面的代码一样在jsp中进行调用:
But when it comes to the application, here in my appplication we mentioned the javascript in .js file and calling in the jsp like below code:
<script src="<%=request.getContextPath()%>/js/monitorScript.js" ></script>
<script src="<%=request.getContextPath()%>/jquery/jquery.js" ></script>
<script src="<%=request.getContextPath()%>/jquery/jquery-1.4.2.min.js" ></script>
<script src="<%=request.getContextPath()%>/jquery/jquery.validate.js" ></script>
<a href="java<!-- no -->script:submitSearchForm();" class="buttonLink"> <bean:message key="SSOSniffer.form.submit" xmlns:bean="#unknown" /></a>
当我调用monitorScript.js中存在的相同方法时,单击提交"按钮时,不会显示任何错误消息.
请帮助这非常紧急
还有另一件事,我该如何在类似
的函数中访问它
函数xxx()
{
///然后在此处验证代码
}
When I am calling the same method present in monitorScript.js, when the submit button is clicked there is no error message is showing.
Please help it is very urgent
and one more thing how can i access it in the function like
function xxx()
{
///the validate code here and then
}
推荐答案
(" ).validate({ 规则:{ cnName:{ 必需的:真, minlength: 3 } }, 消息:{ cnName:{ 必填:" , minlength:" } } });
("#formid").validate({ rules: { cnName : { required :true, minlength: 3 } }, messages : { cnName: { required: "Please enter a name", minlength: "must 3 elements" } } });
但是当涉及到该应用程序时,在我的应用程序中,我们提到了.js文件中的javascript并像下面的代码一样在jsp中进行调用:
But when it comes to the application, here in my appplication we mentioned the javascript in .js file and calling in the jsp like below code:
<script src="<%=request.getContextPath()%>/js/monitorScript.js" ></script>
<script src="<%=request.getContextPath()%>/jquery/jquery.js" ></script>
<script src="<%=request.getContextPath()%>/jquery/jquery-1.4.2.min.js" ></script>
<script src="<%=request.getContextPath()%>/jquery/jquery.validate.js" ></script>
<a href="java<!-- no -->script:submitSearchForm();" class="buttonLink"> <bean:message key="SSOSniffer.form.submit" xmlns:bean="#unknown" /></a>
当我调用monitorScript.js中存在的相同方法时,单击提交"按钮时,不会显示任何错误消息.
请帮助这非常紧急
还有另一件事,我该如何在类似
的函数中访问它
函数xxx()
{
///然后在此处验证代码
}
When I am calling the same method present in monitorScript.js, when the submit button is clicked there is no error message is showing.
Please help it is very urgent
and one more thing how can i access it in the function like
function xxx()
{
///the validate code here and then
}
您需要将这一行移动到JQuery文件之后.
You need to move this line to be after the JQuery files.
<script src="<%=request.getContextPath()%>/js/monitorScript.js" ></script>
这篇关于jQuery验证中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!