名称 | 验证类型 | 正则表达式 |
username | 用户名 | /^a-zA-Z0-9+$/ |
password | 密码 | /^[a-zA-Z0-9]{6,16}$/ |
mobile | 手机号码 | /^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(1[6|7|8][0-9]))\d{8}$/ |
tel | 固定电话 | /^0\d{2,3}-\d{7,8}(-\d{3,5}){0,1}$/ |
phone | 固话+手机【支持分机号】 | /^(0\d{2,3}-\d{7,8}(-\d{3,5}){0,1})|(((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(1[6|7|8][0-9]))\d{8})$/ |
identity | 身份证 | /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/ |
bankAccount | 银行卡号 | /^([1-9]{1})(\d{15}|\d{16}|\d{18})$/ |
currency | 浮点型(保留两位小数) | /^(([1-9]\d*)|0)(.\d{0,2})?$/ |
quantity | 浮点型 | /^(([1-9]\d*)|0)(.\d*)?$/ |
posInt | 正整数 | /^[1-9]\d*$/ |
negInt | 负整数 | /^-[1-9]\d*$/ |
Int | 整数 | /^-?[1-9]\d*$/ |
#将输入的字符变为空
<el-input
v-model="warehouse.warehouseContacterMobile"
:placeholder="$t('请输入')+$t('联系电话')"
name="warehouse_warehouseContacterMobile"
maxlength="11"
show-word-limit
onkeyup="this.value=this.value.replace(/[^\d.]/g,'');"/>
onkeyup将输入的字符变为空
java中使用正则表达式
public static boolean isPureDigital(String str) {
if (str == null || "".equals(str)){
return false;
}
Pattern p;
Matcher m;
p = Pattern.compile("[0-9]*");
m = p.matcher(str);
if (m.matches()){
return true;
}else{
return false;
}
}
public static boolean isBigDecimal(String integer) {
Pattern pattern=Pattern.compile("^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$");
Matcher match=pattern.matcher(integer);
if(match.matches()==false){
return false;
}else{
return true;
}
}
if(!isPureDigital(cols.get(2))){
return I18nUtils.getI18n("单店铺赠品总限量不是正整数");
}