diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js b/ruoyi-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js
index 67cda90d..42d53850 100644
--- a/ruoyi-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js
+++ b/ruoyi-admin/src/main/resources/static/ajax/libs/validate/jquery.validate.extend.js
@@ -1,49 +1,53 @@
/*this is basic form validation using for validation person's basic information author:Clara Guo data:2017/07/20*/
$(document).ready(function(){
$.validator.setDefaults({
- submitHandler: function(form) {
- form.submit();
+ submitHandler: function(form) {
+ form.submit();
}
- });
- //手机号码验证身份证正则合并:(^\d{15}$)|(^\d{17}([0-9]|X)$)
- jQuery.validator.addMethod("isPhone",function(value,element){
+ });
+ // 非法字符验证
+ jQuery.validator.addMethod("specialSign",function(value,element) {
+ var char = /^[^<>"'|\\]+$/;
+ return this.optional(element) || (char.test(value));
+ },"不能包含非法字符:< > \" ' \\\ |");
+ // 手机号码验证身份证正则合并:(^\d{15}$)|(^\d{17}([0-9]|X)$)
+ jQuery.validator.addMethod("isPhone",function(value,element) {
var length = value.length;
- var phone=/^1[3-9]\d{9}$/;
+ var phone = /^1[3-9]\d{9}$/;
return this.optional(element)||(length == 11 && phone.test(value));
},"请填写正确的11位手机号");
- //电话号码验证
- jQuery.validator.addMethod("isTel",function(value,element){
+ // 电话号码验证
+ jQuery.validator.addMethod("isTel",function(value,element) {
var tel = /^(0\d{2,3}-)?\d{7,8}$/g;//区号3,4位,号码7,8位
return this.optional(element) || (tel.test(value));
},"请填写正确的座机号码");
- //姓名校验
- jQuery.validator.addMethod("isName",function(value,element){
- var name=/^[\u4e00-\u9fa5]{2,6}$/;
+ // 姓名校验
+ jQuery.validator.addMethod("isName",function(value,element) {
+ var name = /^[\u4e00-\u9fa5]{2,6}$/;
return this.optional(element) || (name.test(value));
},"姓名只能用汉字,长度2-4位");
- //校验用户名
- jQuery.validator.addMethod("isUserName",function(value,element){
- var userName=/^[a-zA-Z0-9]{2,13}$/;
+ // 校验用户名
+ jQuery.validator.addMethod("isUserName",function(value,element) {
+ var userName = /^[a-zA-Z0-9]{2,13}$/;
return this.optional(element) || (userName).test(value);
},'请输入数字或者字母,不包含特殊字符');
-
- //校验身份证
- jQuery.validator.addMethod("isIdentity",function(value,element){
- var id= /^(\d{15}$|^\d{18}$|^\d{17}(\d|X))$/;
+ // 校验身份证
+ jQuery.validator.addMethod("isIdentity",function(value,element) {
+ var id = /^(\d{15}$|^\d{18}$|^\d{17}(\d|X))$/;
return this.optional(element) || (id.test(value));
},"请输入正确的15或18位身份证号,末尾若为X请大写");
- //校验二代身份证
- jQuery.validator.addMethod("isIdentity18",function(value,element){
- var id= /^(^\d{17}(\d|X))$/;
+ // 校验二代身份证
+ jQuery.validator.addMethod("isIdentity18",function(value,element) {
+ var id = /^(^\d{17}(\d|X))$/;
return this.optional(element) || (id.test(value));
},"请输入正确的18位身份证号,末尾若为X请大写");
- //校验出生日期
- jQuery.validator.addMethod("isBirth",function(value,element){
+ // 校验出生日期
+ jQuery.validator.addMethod("isBirth",function(value,element) {
var birth = /^(19|20)\d{2}-(1[0-2]|0?[1-9])-(0?[1-9]|[1-2][0-9]|3[0-1])$/;
return this.optional(element) || (birth).test(value);
},"出生日期格式示例2000-01-01");
- //校验IP地址
- jQuery.validator.addMethod("isIp",function(value,element){
+ // 校验IP地址
+ jQuery.validator.addMethod("isIp",function(value,element) {
var ip = /^(?:(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:1[0-9][0-9]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:2[0-4][0-9])|(?:25[0-5])|(?:1[0-9][0-9])|(?:[1-9][0-9])|(?:[0-9]))$/;
return this.optional(element) || (ip).test(value);
},"IP地址格式示例127.0.0.1");
@@ -53,7 +57,7 @@ $(document).ready(function(){
jQuery.validator.addMethod("gt", function(value, element, param) {
return value > param;
}, $.validator.format("输入值必须大于{0}"));
- //校验新旧密码是否相同
+ // 校验新旧密码是否相同
jQuery.validator.addMethod("isdiff",function(){
var p1=$("#pwdOld").val();
var p2=$("#pwdNew").val();
@@ -63,7 +67,7 @@ $(document).ready(function(){
return true;
}
});
- //校验新密码和确认密码是否相同
+ // 校验新密码和确认密码是否相同
jQuery.validator.addMethod("issame",function(){
var p3=$("#confirm_password").val();
var p4=$("#pwdNew").val();
@@ -73,7 +77,7 @@ $(document).ready(function(){
return false;
}
});
- //校验基础信息表单
+ // 校验基础信息表单
$("#basicInfoForm").validate({
errorElement:'span',
errorClass:'help-block error-mes',
@@ -133,11 +137,11 @@ $(document).ready(function(){
}
});
- //校验修改密码表单
+ // 校验修改密码表单
$("#modifyPwd").validate({
onfocusout: function(element) { $(element).valid()},
- debug:false, //表示校验通过后是否直接提交表单
- onkeyup:false, //表示按键松开时候监听验证
+ debug:false, // 表示校验通过后是否直接提交表单
+ onkeyup:false, // 表示按键松开时候监听验证
rules:{
pwdOld:{
required:true,
diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/login.js b/ruoyi-admin/src/main/resources/static/ruoyi/login.js
index 1547496b..807ed184 100644
--- a/ruoyi-admin/src/main/resources/static/ruoyi/login.js
+++ b/ruoyi-admin/src/main/resources/static/ruoyi/login.js
@@ -8,12 +8,6 @@ $(function() {
});
});
-$.validator.setDefaults({
- submitHandler: function() {
- login();
- }
-});
-
function login() {
var username = $.common.trim($("input[name='username']").val());
var password = $.common.trim($("input[name='password']").val());
@@ -66,6 +60,9 @@ function validateRule() {
password: {
required: icon + "请输入您的密码",
}
+ },
+ submitHandler: function(form) {
+ login();
}
})
}
diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/register.js b/ruoyi-admin/src/main/resources/static/ruoyi/register.js
index cd0a56ad..1f7b8325 100644
--- a/ruoyi-admin/src/main/resources/static/ruoyi/register.js
+++ b/ruoyi-admin/src/main/resources/static/ruoyi/register.js
@@ -7,12 +7,6 @@ $(function() {
});
});
-$.validator.setDefaults({
- submitHandler: function() {
- register();
- }
-});
-
function register() {
var username = $.common.trim($("input[name='username']").val());
var password = $.common.trim($("input[name='password']").val());
@@ -63,7 +57,8 @@ function validateRule() {
},
password: {
required: true,
- minlength: 5
+ minlength: 5,
+ specialSign: true
},
confirmPassword: {
required: true,
@@ -83,6 +78,9 @@ function validateRule() {
required: icon + "请再次输入您的密码",
equalTo: icon + "两次密码输入不一致"
}
+ },
+ submitHandler: function(form) {
+ register();
}
})
}
diff --git a/ruoyi-admin/src/main/resources/templates/register.html b/ruoyi-admin/src/main/resources/templates/register.html
index c35a5bba..ef1f0944 100644
--- a/ruoyi-admin/src/main/resources/templates/register.html
+++ b/ruoyi-admin/src/main/resources/templates/register.html
@@ -72,6 +72,7 @@
+
diff --git a/ruoyi-admin/src/main/resources/templates/system/user/add.html b/ruoyi-admin/src/main/resources/templates/system/user/add.html
index 51affa89..01749776 100644
--- a/ruoyi-admin/src/main/resources/templates/system/user/add.html
+++ b/ruoyi-admin/src/main/resources/templates/system/user/add.html
@@ -168,7 +168,8 @@
},
password:{
minlength: 5,
- maxlength: 20
+ maxlength: 20,
+ specialSign: true
},
email:{
email:true,
diff --git a/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html b/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html
index 46e136e9..4cb88b1e 100644
--- a/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html
+++ b/ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html
@@ -260,7 +260,8 @@
newPassword: {
required: true,
minlength: 6,
- maxlength: 20
+ maxlength: 20,
+ specialSign: true
},
confirmPassword: {
required: true,
diff --git a/ruoyi-admin/src/main/resources/templates/system/user/profile/resetPwd.html b/ruoyi-admin/src/main/resources/templates/system/user/profile/resetPwd.html
index 32b5ffbb..dfb4ee2a 100644
--- a/ruoyi-admin/src/main/resources/templates/system/user/profile/resetPwd.html
+++ b/ruoyi-admin/src/main/resources/templates/system/user/profile/resetPwd.html
@@ -65,7 +65,8 @@
newPassword: {
required: true,
minlength: 5,
- maxlength: 20
+ maxlength: 20,
+ specialSign: true
},
confirmPassword: {
required: true,
diff --git a/ruoyi-admin/src/main/resources/templates/system/user/resetPwd.html b/ruoyi-admin/src/main/resources/templates/system/user/resetPwd.html
index 4c4b63e2..fb57bd88 100644
--- a/ruoyi-admin/src/main/resources/templates/system/user/resetPwd.html
+++ b/ruoyi-admin/src/main/resources/templates/system/user/resetPwd.html
@@ -31,9 +31,10 @@
$("#form-user-resetPwd").validate({
rules:{
password:{
- required:true,
+ required: true,
minlength: 5,
- maxlength: 20
+ maxlength: 20,
+ specialSign: true
},
},
focusCleanup: true