From 868f5038b0341c54120195dabed4da187e3a18a7 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Fri, 18 Apr 2025 23:23:10 +0530 Subject: [PATCH] added validation for character limit, user can't add more than 200 character for description --- src/components/Activities/CheckCheckOutForm.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/Activities/CheckCheckOutForm.jsx b/src/components/Activities/CheckCheckOutForm.jsx index b947f5cb..93b8069c 100644 --- a/src/components/Activities/CheckCheckOutForm.jsx +++ b/src/components/Activities/CheckCheckOutForm.jsx @@ -12,7 +12,7 @@ import {checkIfCurrentDate} from "../../utils/dateUtils"; const schema = z.object({ markTime: z.string().nonempty({message:"Time is required"}), - description:z.string().optional() + description:z.string().max(200,"description should less than 200 chracters").optional() }); const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => { @@ -29,7 +29,8 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => { reset, setValue, } = useForm({ - resolver: zodResolver(schema), + resolver: zodResolver( schema ), + mode:"onChange" }); const onSubmit = ( data ) => @@ -84,7 +85,8 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => { rows="3" name="description" className="form-control" - {...register("description")} + {...register( "description" )} + maxLength={200} /> {errors.description && (

{errors.description.message}