public void validateID(AjaxBehaviorEvent event) {

    String idValidate = IclubWebHelper.validateId(bean.getPIdNum(), bean.getPGender());
    if (idValidate != null && !idValidate.trim().equalsIgnoreCase("")) {

      IclubWebHelper.addMessage(idValidate, FacesMessage.SEVERITY_ERROR);
    } else {
      String dateOfBirth = bean.getPIdNum().toString().substring(0, 6);
      SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd");
      try {
        Date dateOfBirthD = formatter.parse(dateOfBirth);
        bean.setPDob(dateOfBirthD);
      } catch (ParseException e) {
        e.printStackTrace();
      }
    }
  }
  public boolean validateForm(boolean flag) {
    boolean ret = true;
    if (bean.getPFName() == null || bean.getPFName().trim().equalsIgnoreCase("")) {
      IclubWebHelper.addMessage(("First Name Cannot be empty"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }
    if (bean.getPLName() == null || bean.getPLName().trim().equalsIgnoreCase("")) {
      IclubWebHelper.addMessage(("Last Name Cannot be empty"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }
    if (bean.getPMobile() == null || bean.getPMobile().trim().equalsIgnoreCase("")) {
      IclubWebHelper.addMessage(("Mobile Number Cannot be empty"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }

    if (bean.getPGender() == null || bean.getPGender().trim().equalsIgnoreCase("")) {
      IclubWebHelper.addMessage(("Gender Cannot be empty"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }

    if (bean.getPIdNum() == null || bean.getPIdNum().trim().equalsIgnoreCase("")) {
      IclubWebHelper.addMessage(("Id Number Cannot be empty"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }
    if (bean.getIclubIdType() == null) {
      IclubWebHelper.addMessage(("Please Select ID Type"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }
    if (bean.getPIsPensioner() == null || bean.getPIsPensioner().trim().equalsIgnoreCase("")) {
      IclubWebHelper.addMessage(("Please Select Pensioner"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }
    if (bean.getPDob() == null) {
      IclubWebHelper.addMessage(("Please Select DOB"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    } else if (IclubWebHelper.calculateYearDiff(bean.getPDob().getTime()) <= 18) {
      IclubWebHelper.addMessage(("You must be over 18 years"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }
    if (bean.getPIdIssueDt() == null) {
      IclubWebHelper.addMessage(("Please Select IssueDate"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    } else if (IclubWebHelper.isCurrentDate(bean.getPIdIssueDt().getTime())) {
      IclubWebHelper.addMessage(
          ("Issue Date Should be less than Current Date"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    } else if (bean.getPIdExpiryDt() != null
        && !IclubWebHelper.isCurrentDate(bean.getPIdExpiryDt().getTime())) {
      IclubWebHelper.addMessage(
          ("Expiry Date Should be greater than Current Date"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    } else if (bean.getPIdExpiryDt() != null
        && !IclubWebHelper.isCurrentDate(bean.getPIdExpiryDt().getTime())) {
      IclubWebHelper.addMessage(
          ("Expiry Date Should be greater than Current Date"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    } else if (((Long) bean.getPIdIssueDt().getTime())
            .compareTo(((Long) bean.getPIdExpiryDt().getTime()))
        >= 0) {
      IclubWebHelper.addMessage(
          (" Id Issue Date Should be less than Expiry Date"), FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }
    String idValidate = IclubWebHelper.validateId(bean.getPIdNum(), bean.getPGender());
    if (idValidate != null && !idValidate.trim().equalsIgnoreCase("")) {

      IclubWebHelper.addMessage(idValidate, FacesMessage.SEVERITY_ERROR);
      ret = ret && false;
    }
    return ret;
  }