Remove client side validation for the min-/maxlength of various fields

This commit is contained in:
Andreas Svanberg 2025-01-15 10:15:43 +01:00
parent 5d475c961c
commit 348afe1723
2 changed files with 18 additions and 2 deletions

@ -22,7 +22,15 @@ public class IdeaTholanderCompletionPanel extends Panel {
private void textField(String id, IModel<String> model) {
TextArea<String> textArea = new TextArea<>(id, model);
textArea.add(StringValidator.maximumLength(TholanderBox.MAX_CHARS));
textArea.add(
new StringValidator(null, TholanderBox.MAX_CHARS) {
@Override
protected boolean hasLengthAttribute(String tagName) {
// remove the maxlength attribute from the tag to disable client side validation
return false;
}
}
);
textArea.setRequired(true);
add(textArea);

@ -307,7 +307,15 @@ public class ProjectIdeaSubmissionPanel extends GenericPanel<Idea> {
LambdaModel.of(getModel(), Idea::getTitle, Idea::setTitle)
);
title.setRequired(true);
title.add(StringValidator.minimumLength(MIN_TITLE_LENGTH));
title.add(
new StringValidator(MIN_TITLE_LENGTH, null) {
@Override
protected boolean hasLengthAttribute(String tagName) {
// remove the minlength attribute from the tag to disable client side validation
return false;
}
}
);
add(new ComponentFeedbackPanel("titleFeedback", title));
add(title);
}