提交 f4034696 编写于 作者: Skyeye云's avatar Skyeye云

验证组件添加金钱验证

上级 dcd15a15
...@@ -19,5 +19,6 @@ public class ObjectConstant { ...@@ -19,5 +19,6 @@ public class ObjectConstant {
public static final String URL = "url";//请求参数url校验 public static final String URL = "url";//请求参数url校验
public static final String IP = "ip";//请求参数ip校验 public static final String IP = "ip";//请求参数ip校验
public static final String POSTCODE = "postcode";//请求参数国内邮编校验 public static final String POSTCODE = "postcode";//请求参数国内邮编校验
public static final String DOUBLE = "double";//请求参数验证小数点后两位,一般用于金钱验证
} }
...@@ -224,6 +224,20 @@ public class ToolUtil { ...@@ -224,6 +224,20 @@ public class ToolUtil {
return match(regex, str); 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 * @Title: getTimeAndToString
...@@ -314,6 +328,11 @@ public class ToolUtil { ...@@ -314,6 +328,11 @@ public class ToolUtil {
if(!ToolUtil.isPostalcode(str)) if(!ToolUtil.isPostalcode(str))
return "国内邮编类型不正确"; return "国内邮编类型不正确";
break; break;
case ObjectConstant.DOUBLE://验证小数点后两位,一般用于金钱验证不正确
if (!ToolUtil.isBlank(str))
if(!ToolUtil.isDouble(str))
return "小数格式类型不正确";
break;
default: default:
break; break;
} }
......
...@@ -118,6 +118,10 @@ ...@@ -118,6 +118,10 @@
/(^\d{15}$)|(^\d{17}(x|X|\d)$)/ /(^\d{15}$)|(^\d{17}(x|X|\d)$)/
, '请输入正确的身份证号' , '请输入正确的身份证号'
] ]
, double: [//验证小数点后两位,一般用于金钱验证
/^[0-9]+(.[0-9]{1,2})?$/
, '请输入正确正数,小数点后最多两位'
]
}; //表单验证 }; //表单验证
this.tile = tile; this.tile = tile;
......
...@@ -7,6 +7,7 @@ phone 手机号校验 ...@@ -7,6 +7,7 @@ phone 手机号校验
url url校验 url url校验
ip ip地址校验 ip ip地址校验
postcode 国内邮编校验 postcode 国内邮编校验
double 验证小数点后两位,一般用于金钱验证
状态码属性: HTML->CSS 新建:state-new 线上:state-up 线下:state-down 错误码:state-error 状态码属性: HTML->CSS 新建:state-new 线上:state-up 线下:state-down 错误码:state-error
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册