Пример #1
0
  private boolean checkLength(int length) {

    if (length > getInputLength()) {
      Tool.showToastMsg(
          context, item.getCaption() + "输入内容不能超过" + getInputLength() + "位", AlertType.ERR);
      return false;
    }
    return true;
  }
Пример #2
0
  private boolean checkData(String data) {
    if (data.equals("")) return true;
    if (item.getVerifytype().equalsIgnoreCase("amount")) {
      try {
        if (data.endsWith(".")) return true;
        else if (data.indexOf(".") != -1) {
          data = data.substring(data.indexOf("."), data.length());
          if (data.length() > 3) {
            Tool.showToastMsg(context, item.getCaption() + "只能输入2位小数!", AlertType.ERR);
            return false;
          }
        } else {
          if (Double.parseDouble(data) > getMaxValue()) {

            Tool.showToastMsg(context, item.getCaption() + "不能大于" + getMaxValue(), AlertType.ERR);
            return false;
          }
          if (Integer.parseInt(data) < getMinValue()) {
            Tool.showToastMsg(context, item.getCaption() + "不能小于" + getMinValue(), AlertType.ERR);
            return false;
          }
        }
      } catch (Exception ex) {
        return false;
      }
    } else if (item.getVerifytype().equalsIgnoreCase("number")) {
      try {
        if (Integer.parseInt(data) > getMaxValue()) {
          Tool.showToastMsg(context, item.getCaption() + "不能大于" + getMaxValue(), AlertType.ERR);
          return false;
        }
        if (Integer.parseInt(data) < getMinValue()) {
          Tool.showToastMsg(context, item.getCaption() + "不能小于" + getMinValue(), AlertType.ERR);
          return false;
        }
      } catch (Exception ex) {
        return false;
      }
    }
    return true;
  }