From f40346961e8105296edb116632501fe4359eb57a Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Tue, 6 Nov 2018 10:23:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=BB=84=E4=BB=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=87=91=E9=92=B1=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skyeye/common/object/ObjectConstant.java | 1 + .../java/com/skyeye/common/util/ToolUtil.java | 19 +++++++++++++++++++ .../src/main/webapp/assets/lib/winui/winui.js | 4 ++++ skyeye-web/src/main/webapp/ref.txt | 1 + 4 files changed, 25 insertions(+) diff --git a/skyeye-common/src/main/java/com/skyeye/common/object/ObjectConstant.java b/skyeye-common/src/main/java/com/skyeye/common/object/ObjectConstant.java index 7c1c5308d..62ee1897c 100644 --- a/skyeye-common/src/main/java/com/skyeye/common/object/ObjectConstant.java +++ b/skyeye-common/src/main/java/com/skyeye/common/object/ObjectConstant.java @@ -19,5 +19,6 @@ public class ObjectConstant { public static final String URL = "url";//请求参数url校验 public static final String IP = "ip";//请求参数ip校验 public static final String POSTCODE = "postcode";//请求参数国内邮编校验 + public static final String DOUBLE = "double";//请求参数验证小数点后两位,一般用于金钱验证 } diff --git a/skyeye-common/src/main/java/com/skyeye/common/util/ToolUtil.java b/skyeye-common/src/main/java/com/skyeye/common/util/ToolUtil.java index 6c81a8ad3..712016bf2 100644 --- a/skyeye-common/src/main/java/com/skyeye/common/util/ToolUtil.java +++ b/skyeye-common/src/main/java/com/skyeye/common/util/ToolUtil.java @@ -224,6 +224,20 @@ public class ToolUtil { return match(regex, str); } + /** + * + * @Title: isDouble + * @Description: 验证小数点后两位,一般用于金钱验证 + * @param @param str + * @param @return 参数 + * @return boolean 返回类型 + * @throws + */ + public static boolean isDouble(String str) { + String regex = "^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$"; + return match(regex, str); + } + /** * * @Title: getTimeAndToString @@ -314,6 +328,11 @@ public class ToolUtil { if(!ToolUtil.isPostalcode(str)) return "国内邮编类型不正确"; break; + case ObjectConstant.DOUBLE://验证小数点后两位,一般用于金钱验证不正确 + if (!ToolUtil.isBlank(str)) + if(!ToolUtil.isDouble(str)) + return "小数格式类型不正确"; + break; default: break; } diff --git a/skyeye-web/src/main/webapp/assets/lib/winui/winui.js b/skyeye-web/src/main/webapp/assets/lib/winui/winui.js index 4a18b6d04..c4bfbf0ec 100644 --- a/skyeye-web/src/main/webapp/assets/lib/winui/winui.js +++ b/skyeye-web/src/main/webapp/assets/lib/winui/winui.js @@ -118,6 +118,10 @@ /(^\d{15}$)|(^\d{17}(x|X|\d)$)/ , '请输入正确的身份证号' ] + , double: [//验证小数点后两位,一般用于金钱验证 + /^[0-9]+(.[0-9]{1,2})?$/ + , '请输入正确正数,小数点后最多两位' + ] }; //表单验证 this.tile = tile; diff --git a/skyeye-web/src/main/webapp/ref.txt b/skyeye-web/src/main/webapp/ref.txt index 7feb6a6de..3988bea21 100644 --- a/skyeye-web/src/main/webapp/ref.txt +++ b/skyeye-web/src/main/webapp/ref.txt @@ -7,6 +7,7 @@ phone 手机号校验 url url校验 ip ip地址校验 postcode 国内邮编校验 +double 验证小数点后两位,一般用于金钱验证 状态码属性: HTML->CSS 新建:state-new 线上:state-up 线下:state-down 错误码:state-error -- GitLab