diff --git a/frontend/src/common/constants/validation_messages.json b/frontend/src/common/constants/validation_messages.json index 96ea80bb9..d6d6668c6 100644 --- a/frontend/src/common/constants/validation_messages.json +++ b/frontend/src/common/constants/validation_messages.json @@ -163,7 +163,7 @@ "transactionId": { "defaultMessage": "Invalid transaction ID", "length": { - "messageTemplate": "Transaction ID length must be no longer than :max characters", + "messageTemplate": "Maximum :max characters", "placeholders": [":max"] } } diff --git a/frontend/src/features/permits/pages/Refund/RefundPage.tsx b/frontend/src/features/permits/pages/Refund/RefundPage.tsx index d741d7a2c..cbb8ed83a 100644 --- a/frontend/src/features/permits/pages/Refund/RefundPage.tsx +++ b/frontend/src/features/permits/pages/Refund/RefundPage.tsx @@ -69,8 +69,15 @@ const transactionIdRules = { requiredMessage() ); }, - validateTransactionId: (value: Optional) => { - return (value && value.length <= 15) || invalidTranactionIdLength(15); + validateTransactionId: ( + value: Optional, + formValues: RefundFormData, + ) => { + return ( + !formValues.shouldUsePrevPaymentMethod || + (value && value.length <= 15) || + invalidTranactionIdLength(15) + ); }, }, }; @@ -210,6 +217,7 @@ export const RefundPage = ({ const usePrev = shouldUsePrev === "true"; setShouldUsePrevPaymentMethod(usePrev); setValue("refundOnlineMethod", usePrev ? getRefundOnlineMethod() : ""); + setValue("transactionId", ""); clearErrors("transactionId"); }; @@ -227,6 +235,7 @@ export const RefundPage = ({ e: React.ChangeEvent, ) => { const formattedValue = filterNonNumericValue(e.target.value); + handleRefundMethodChange("true"); setValue("transactionId", formattedValue, { shouldValidate: true }); };