show error in numeric field
This commit is contained in:
@@ -34,7 +34,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
proposed_amount: Yup.string().required(t("ConfirmDialog.amount_error")),
|
||||
proposed_amount: Yup.number().positive(t("ConfirmDialog.proposed_amount_positive")).required(t("ConfirmDialog.proposed_amount_error")),
|
||||
})
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
@@ -68,9 +68,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
|
||||
formik.setFieldValue("description", event.target.value)
|
||||
};
|
||||
const handleAmountChange = (event) => {
|
||||
if (/^\d*$/.test(event.target.value)) {
|
||||
formik.setFieldValue("proposed_amount", event.target.value);
|
||||
}
|
||||
formik.setFieldValue("proposed_amount", event.target.value);
|
||||
};
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
@@ -130,7 +128,6 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
|
||||
type="number"
|
||||
inputProps={{
|
||||
min: 0,
|
||||
inputMode: "numeric",
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
|
||||
@@ -34,9 +34,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
|
||||
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
approved_amount: Yup.string().required(
|
||||
t("ConfirmDialog.approved_amount_error")
|
||||
),
|
||||
approved_amount: Yup.number().positive(t("ConfirmDialog.approved_amount_positive")).required(t("ConfirmDialog.approved_amount_error"))
|
||||
});
|
||||
const formik = useFormik({
|
||||
initialValues: {
|
||||
@@ -70,9 +68,7 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
|
||||
formik.setFieldValue("description", event.target.value)
|
||||
};
|
||||
const handleAmountChange = (event) => {
|
||||
if (/^\d*$/.test(event.target.value)) {
|
||||
formik.setFieldValue("approved_amount", event.target.value);
|
||||
}
|
||||
formik.setFieldValue("approved_amount", event.target.value);
|
||||
};
|
||||
const handleUploadChange = (event) => {
|
||||
const uploadedFile = event.target?.files?.[0];
|
||||
@@ -132,7 +128,6 @@ const Confirm = ({rowId, fetchUrl, mutate}) => {
|
||||
type="number"
|
||||
inputProps={{
|
||||
min: 0,
|
||||
inputMode: "numeric",
|
||||
pattern: "[0-9]*",
|
||||
}}
|
||||
variant="outlined"
|
||||
|
||||
Reference in New Issue
Block a user