Compare commits

..

1 Commits

Author SHA1 Message Date
164271a6e5 Remove all client-side validation and rely on server-side validation
Gives better error messages to the user.
2025-01-15 10:52:43 +01:00
3 changed files with 10 additions and 19 deletions

@ -22,15 +22,7 @@ public class IdeaTholanderCompletionPanel extends Panel {
private void textField(String id, IModel<String> model) {
TextArea<String> textArea = new TextArea<>(id, model);
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.add(StringValidator.maximumLength(TholanderBox.MAX_CHARS));
textArea.setRequired(true);
add(textArea);

@ -17,7 +17,14 @@
an idea if you couldn't find any suitable supervisor provided ideas.
</div>
<form wicket:id="ideaForm">
<!--
Turn off all client-side validation using novalidate.
All input is validated server-side, and we want to validate it
that way to get nice error messages.
However, we also want to maintain the required/minlength/whatever
attributes on the input fields for accessibility.
-->
<form wicket:id="ideaForm" novalidate>
<div class="mb-3">
<label class="col-form-label" wicket:for="title">Title</label>
<p class="form-text">

@ -307,15 +307,7 @@ public class ProjectIdeaSubmissionPanel extends GenericPanel<Idea> {
LambdaModel.of(getModel(), Idea::getTitle, Idea::setTitle)
);
title.setRequired(true);
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;
}
}
);
title.add(StringValidator.minimumLength(MIN_TITLE_LENGTH));
add(new ComponentFeedbackPanel("titleFeedback", title));
add(title);
}