jquery validate + Bootstraper 将默认值放到message_bs_cn中,不需要每次设定
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<link href="${ctx}/static/styles/quickstart.css" type="text/css" rel="stylesheet" />
|
||||
<script src="${ctx}/static/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="${ctx}/static/jquery-validation/1.9.0/jquery.validate.min.js" type="text/javascript"></script>
|
||||
<script src="${ctx}/static/jquery-validation/1.9.0/messages_cn.js" type="text/javascript"></script>
|
||||
<script src="${ctx}/static/jquery-validation/1.9.0/messages_bs_cn.js" type="text/javascript"></script>
|
||||
|
||||
|
||||
<sitemesh:head/>
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
//聚焦第一个输入框
|
||||
$("#name").focus();
|
||||
//为inputForm注册validate函数
|
||||
$("#inputForm").validate({
|
||||
errorElement: "span"
|
||||
});
|
||||
$("#inputForm").validate();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
<title>登录页</title>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#loginForm").validate({
|
||||
errorElement: "span"
|
||||
});
|
||||
$("#loginForm").validate();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
//聚焦第一个输入框
|
||||
$("#name").focus();
|
||||
//为inputForm注册validate函数
|
||||
$("#inputForm").validate({
|
||||
errorElement: "span"
|
||||
});
|
||||
$("#inputForm").validate();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
$("#loginName").focus();
|
||||
//为inputForm注册validate函数
|
||||
$("#inputForm").validate({
|
||||
errorElement: "span",
|
||||
rules: {
|
||||
loginName: {
|
||||
remote: "${ctx}/register/checkLoginName"
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
//聚焦第一个输入框
|
||||
$("#task_title").focus();
|
||||
//为inputForm注册validate函数
|
||||
$("#inputForm").validate({
|
||||
errorElement: "span"
|
||||
});
|
||||
$("#inputForm").validate();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
+5
-1
@@ -20,4 +20,8 @@ jQuery.extend(jQuery.validator.messages, {
|
||||
range: jQuery.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),
|
||||
max: jQuery.validator.format("请输入一个最大为 {0} 的值"),
|
||||
min: jQuery.validator.format("请输入一个最小为 {0} 的值")
|
||||
});
|
||||
});
|
||||
|
||||
jQuery.extend(jQuery.validator.defaults, {
|
||||
errorElement: "span"
|
||||
});
|
||||
@@ -7,6 +7,7 @@
|
||||
<head>
|
||||
<title>综合演示用例</title>
|
||||
<script src="${ctx}/static/jquery-validation/1.9.0/jquery.validate.min.js" type="text/javascript"></script>
|
||||
<script src="${ctx}/static/jquery-validation/1.9.0/messages_bs_cn.js" type="text/javascript"></script>
|
||||
<link href="${ctx}/static/jquery-validation/1.9.0/validate.css" type="text/css" rel="stylesheet" />
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
@@ -14,7 +15,6 @@
|
||||
|
||||
//为inputForm注册validate函数
|
||||
$("#inputForm").validate({
|
||||
errorElement: "span",
|
||||
rules: {
|
||||
loginName: {
|
||||
remote: "${ctx}/account/user/checkLoginName?oldLoginName=" + encodeURIComponent('${user.loginName}')
|
||||
@@ -29,9 +29,9 @@
|
||||
errorContainer: "#messageBox",
|
||||
errorPlacement: function(error, element) {
|
||||
if ( element.is(":checkbox") )
|
||||
error.appendTo ( element.parent().next() );
|
||||
error.appendTo(element.parent().next());
|
||||
else
|
||||
error.insertAfter( element );
|
||||
error.insertAfter(element);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#loginForm").validate({
|
||||
errorElement: "span"
|
||||
});
|
||||
$("#loginForm").validate();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
+5
-1
@@ -20,4 +20,8 @@ jQuery.extend(jQuery.validator.messages, {
|
||||
range: jQuery.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),
|
||||
max: jQuery.validator.format("请输入一个最大为 {0} 的值"),
|
||||
min: jQuery.validator.format("请输入一个最小为 {0} 的值")
|
||||
});
|
||||
});
|
||||
|
||||
jQuery.extend(jQuery.validator.defaults, {
|
||||
errorElement: "span"
|
||||
});
|
||||
Reference in New Issue
Block a user