diff --git a/src/components/Project/ManageProjectInfo.jsx b/src/components/Project/ManageProjectInfo.jsx index 8e68b5f3..08808fa8 100644 --- a/src/components/Project/ManageProjectInfo.jsx +++ b/src/components/Project/ManageProjectInfo.jsx @@ -41,7 +41,14 @@ const ManageProjectInfo = ( {project,handleSubmitForm, onClose} ) => return num; }), - } ) + } ) .refine((data) => { + const start = new Date(data.startDate); + const end = new Date(data.endDate); + return end > start; + }, { + path: ['endDate'], // attaches the error to the endDate field + message: 'End Date must be greater than Start Date', + }); const {register, control, handleSubmit, formState: {errors}, reset, getValues} = useForm( {