Skip to content

docs: add incomplete input to date time picker docs #4362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions articles/components/_input-field-common-features.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ An instruction text at the top of the form explaining the required indicator is
====
// end::required[]

// tag::incomplete-input[]
[#incomplete-input]
.Incomplete Input
[%collapsible]
====
Incomplete input refers to when an input has a valid value while the other is empty. When an incomplete value is entered, the field resets the value to empty and becomes invalid. This constraint is non-configurable and enabled by default.
====
// end::incomplete-input[]

// tag::min-and-max-length[]
[#min-and-max-length]
Expand Down
2 changes: 1 addition & 1 deletion articles/components/date-time-picker/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Date Time Picker provides a validation mechanism based on constraints. Constrain

Below is a list of supported constraints with more detailed information:

include::{articles}/components/_input-field-common-features.adoc[tags=bad-input;required]
include::{articles}/components/_input-field-common-features.adoc[tags=bad-input;incomplete-input;required]

[#min-and-max-value]
.Min & Max Values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ export class Example extends LitElement {
!datePicker.value && !!(datePicker.inputElement as HTMLInputElement).value;
const hasBadTimeInput =
!timePicker.value && !!(timePicker.inputElement as HTMLInputElement).value;
const hasIncompleteInput =
(datePicker.value && !timePicker.value) || (timePicker.value && !datePicker.value);

if (hasBadDateInput || hasBadTimeInput) {
this.errorMessage = 'Invalid date or time';
} else if (hasIncompleteInput) {
this.errorMessage = 'Missing date or time';
} else if (!field.value) {
this.errorMessage = 'Field is required';
} else if (field.value < field.min!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ function Example() {
!datePicker.value && !!(datePicker.inputElement as HTMLInputElement).value;
const hasBadTimeInput =
!timePicker.value && !!(timePicker.inputElement as HTMLInputElement).value;
const hasIncompleteInput =
(datePicker.value && !timePicker.value) || (timePicker.value && !datePicker.value);

if (hasBadDateInput || hasBadTimeInput) {
errorMessage.value = 'Invalid date or time';
} else if (hasIncompleteInput) {
errorMessage.value = 'Missing date or time';
} else if (!field.value) {
errorMessage.value = 'Field is required';
} else if (field.value < field.min!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public DateTimePickerCustomValidation() {
.setHelperText("Open Mondays-Fridays, 8:00-12:00, 13:00-16:00");
dateTimePicker.setStep(Duration.ofMinutes(30));
dateTimePicker.setI18n(new DateTimePickerI18n()
.setBadInputErrorMessage("Invalid date or time format"));
.setBadInputErrorMessage("Invalid date or time format")
.setIncompleteInputErrorMessage("Missing date or time"));
add(dateTimePicker);

String errorMessage = "The selected day of week or time is not available";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public DateTimePickerValidation() {
dateTimePicker.setI18n(new DateTimePickerI18n()
.setRequiredErrorMessage("Field is required")
.setBadInputErrorMessage("Invalid date or time format")
.setIncompleteInputErrorMessage("Missing date or time")
.setMinErrorMessage("Too early, choose another date and time")
.setMaxErrorMessage("Too late, choose another date and time"));

Expand Down
Loading