private String validateCellvalue(String strCellvalue, int iKey) throws Exception {
if(iKey == 0&&UtilityFunction.isBlank(strCellvalue)){
this.isvalidateOK = false;
return "<font color=red>Merchant Trans ID is missing.</font>";
}else if (iKey == 1 && UtilityFunction.isBlank(strCellvalue)) {
this.isvalidateOK = false;
return "<font color=red>First Name is missing.</font>";
} else {
return strCellvalue;
}
}
这里已经判断了Merchant id和name是否为空了,为空就报错误消息。现在想多判断(& + \) 这个2个标点符号,如果有就报错误消息。不知道如何判断?请教各位。在线等大家
if(iKey == 0&&UtilityFunction.isBlank(strCellvalue)){
this.isvalidateOK = false;
return "<font color=red>Merchant Trans ID is missing.</font>";
}else if (iKey == 1 && UtilityFunction.isBlank(strCellvalue)) {
this.isvalidateOK = false;
return "<font color=red>First Name is missing.</font>";
} else {
return strCellvalue;
}
}
这里已经判断了Merchant id和name是否为空了,为空就报错误消息。现在想多判断(& + \) 这个2个标点符号,如果有就报错误消息。不知道如何判断?请教各位。在线等大家
boolean flag = false;
if (!((string == null) && (string.trim().length() == 0))) {
if (string.matches("[0-9]+")) {
flag = true;
}
}
return flag;
}是像判断是否数字这样,先写个方法是否那2个标点符号,然后再判断吧?
if (UtilityFunction.isBlank(strCellvalue)) {
if (iKey == 0) {
this.isvalidateOK = false;
return " <font color=red>Merchant Trans ID is missing. </font>";
} else if (iKey == 1) {
this.isvalidateOK = false;
return " <font color=red>First Name is missing. </font>";
}
}
else {
if (XXXX) {
}
return strCellvalue;
}
}
if (strCellvalue.indexOf('&') > 0) {
return "Error message";
}
if (strCellvalue.indexOf('\') > 0) {
return "Error message";
}
return strCellvalue;
}
我写的不一定对,你需要测试下
return "你输入中含有\和&这两个特殊字符";
}