Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6069662

Browse files
fix date input field require validation
1 parent3bccf4a commit6069662

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

‎client/packages/lowcoder/src/comps/comps/dateComp/dateComp.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const timeValidationFields = (children: CommonChildrenType, dateType: PickerMode
119119
functionvalidate(
120120
props:RecordConstructorToView<typeofvalidationChildren>&{
121121
value:{value:string};
122+
showTime:boolean;
122123
}
123124
):{
124125
validateStatus:"success"|"warning"|"error";
@@ -127,10 +128,9 @@ function validate(
127128
if(props.customRule){
128129
return{validateStatus:"error",help:props.customRule};
129130
}
131+
constcurrentDateTime=dayjs(props.value.value,DateParser);
130132

131-
constcurrentDateTime=dayjs(dayjs(props.value.value),DATE_TIME_FORMAT);
132-
133-
if(props.required&&!currentDateTime.isValid()){
133+
if(props.required&&(props.value.value===''||!currentDateTime.isValid())){
134134
return{validateStatus:"error",help:trans("prop.required")};
135135
}
136136

@@ -169,6 +169,7 @@ export const datePickerControl = new UICompBuilder(childrenMap, (props) => {
169169
if(props.value.value!==''){
170170
time=dayjs(props.value.value,DateParser);
171171
}
172+
172173
returnprops.label({
173174
required:props.required,
174175
style:props.style,

‎client/packages/lowcoder/src/util/dateTimeUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ export const TIME_12_FORMAT = "HH:mm:ss:a";
7171
exportconstTIME_FORMAT_MINUTES="HH:mm"
7272
exportconstDATE_FORMAT="YYYY-MM-DD";
7373
exportconstDATE_FORMAT_EN="MM/DD/YYYY";
74+
exportconstDATE_FORMAT_EN_2="M/D/YYYY";
7475
exportconstDATE_TIME_FORMAT="YYYY-MM-DD HH:mm:ss";
7576
exportconstDATE_TIME_12_FORMAT="YYYY-MM-DD HH:mm:ss:a";
7677
exportconstTIMESTAMP_FORMAT="x";
77-
exportconstDateParser=[DATE_TIME_FORMAT,DATE_TIME_12_FORMAT,DATE_FORMAT,TIMESTAMP_FORMAT,DATE_FORMAT_EN];
78+
exportconstDateParser=[DATE_TIME_FORMAT,DATE_TIME_12_FORMAT,DATE_FORMAT,TIMESTAMP_FORMAT,DATE_FORMAT_EN,DATE_FORMAT_EN_2];
7879
exportconstTimeParser=[TIME_12_FORMAT,TIME_FORMAT,TIMESTAMP_FORMAT];
7980
exporttypePickerMode="date"|"week"|"month"|"quarter"|"year";
8081

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp