Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web-ui
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WEBGDE-Components
web-ui
Commits
4acbf205
Commit
4acbf205
authored
Jan 25, 2024
by
Jhunel Adam Calub
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-WG-484' into 'development-mobile'
WG-484 validdate input See merge request
!81
parents
2396ede2
b1bec4d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
validateInput.js
...ebContent/WebGde-Widgets/DataInputWidget/validateInput.js
+28
-16
No files found.
WebGde/WebContent/WebGde-Widgets/DataInputWidget/validateInput.js
View file @
4acbf205
...
...
@@ -234,32 +234,44 @@ const validateDate = (validation, value) => {
try
{
if
(
mandatory
&&
(
value
.
length
===
0
||
!
value
.
match
(
/
\S
/g
)))
return
{
valid
:
false
,
errors
:
[
'Field is required.'
]
}
if
(
validdate
===
"past"
){
if
(
value
.
length
===
0
)
{
return
{
valid
:
true
};
if
(
validdate
!=
""
){
if
(
value
.
length
===
0
)
{
return
{
valid
:
true
};
}
const
enteredDateParts
=
value
.
split
(
'-'
);
if
(
enteredDateParts
.
length
!==
3
)
{
return
{
valid
:
false
,
errors
:
[
'Invalid date format.'
]
};
return
{
valid
:
false
,
errors
:
[
'Invalid date format.'
]
};
}
const
enteredYear
=
parseInt
(
enteredDateParts
[
0
]);
const
enteredMonth
=
parseInt
(
enteredDateParts
[
1
])
-
1
;
// Months are 0-based
const
enteredDay
=
parseInt
(
enteredDateParts
[
2
]);
const
enteredDate
=
new
Date
(
enteredYear
,
enteredMonth
,
enteredDay
);
const
currentDate
=
new
Date
();
console
.
log
(
currentDate
);
if
(
enteredDate
<
currentDate
)
{
return
{
valid
:
true
};
// The date is in the past
}
else
{
return
{
valid
:
false
,
errors
:
[
'Future date not allowed.'
]
};
}
const
enteredDate
=
new
Date
(
enteredYear
,
enteredMonth
,
enteredDay
);
}
const
currentDate
=
new
Date
();
console
.
log
(
currentDate
);
switch
(
validdate
){
case
"past"
:
if
(
enteredDate
<
currentDate
)
{
return
{
valid
:
true
};
// The date is in the past
}
else
{
return
{
valid
:
false
,
errors
:
[
'Only past dates are allowed.'
]
};
}
case
"current"
:
if
(
enteredDate
=
currentDate
)
{
return
{
valid
:
true
};
// The date is today
}
else
{
return
{
valid
:
false
,
errors
:
[
'Only current date is allowed.'
]
};
}
case
"future"
:
if
(
enteredDate
>
currentDate
)
{
return
{
valid
:
true
};
// The date is in the future
}
else
{
return
{
valid
:
false
,
errors
:
[
'Only future dates are allowed.'
]
};
}
}
}
return
{
valid
:
true
}
}
catch
(
err
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment