public bool validate(AFField field, StringBuilder errorMsgs, AFValidationRule rule) { bool validationIsFine = true; if (Utils.IsFieldNumberField(field)) { TextBox numberField = (TextBox)field.getFieldView(); try { if (!String.IsNullOrEmpty(numberField.Text) && Convert.ToDouble(numberField.Text) > Convert.ToDouble(rule.getValue())) { validationIsFine = false; } } catch (Exception ex) //catch convert exception { validationIsFine = true; //if there is no number in field we cant validate its value Debug.WriteLine(ex.StackTrace); } } if (!validationIsFine) { errorMsgs.Append(Localization.translate("validation.maxval") + " " + rule.getValue()); } return validationIsFine; }
public bool validate(AFField field, StringBuilder errorMsgs, AFValidationRule rule) { bool validationIsFine = true; if (Utils.IsFieldWritable(field.getFieldInfo().getWidgetType())) { TextBox textfield = (TextBox)field.getFieldView(); if (textfield.Text != null && textfield.Text.Length > Convert.ToInt32(rule.getValue())) { validationIsFine = false; } } if (field.getFieldInfo().getWidgetType().Equals(SupportedWidgets.PASSWORD)) { PasswordBox textfield = (PasswordBox)field.getFieldView(); if (textfield.Password != null && textfield.Password.Length > Convert.ToInt32(rule.getValue())) { validationIsFine = false; } } if (!validationIsFine) { errorMsgs.Append(Localization.translate("validation.maxchars")); } return validationIsFine; }
public bool validate(AFField field, StringBuilder errorMsgs, AFValidationRule rule) { bool validationIsFine = true; Object otherData = ((AFForm)field.getParent()).getDataFromFieldWithId(rule.getValue()); if (otherData != null) { if (Utils.IsFieldNumberField(field)) { //TODO pro cisla } if (field.getFieldInfo().getWidgetType().Equals(SupportedWidgets.CALENDAR)) { Object fieldData = ((AFForm)field.getParent()).getDataFromFieldWithId(field.getId()); if (fieldData != null) { DateTime? date = Utils.ParseDate(fieldData.ToString()); DateTime? otherDate = Utils.ParseDate(otherData.ToString()); if (date > otherDate) { validationIsFine = false; } } } if (!validationIsFine) { String otherFieldLabelText = (field.getParent()).getFieldById(rule.getValue()).getFieldInfo().getLabelText(); errorMsgs.Append(Localization.translate("validation.lessthan") + " " + Localization.translate(otherFieldLabelText)); } } return validationIsFine; }