diff --git a/src/products/components/ProductPricing/ProductPricing.tsx b/src/products/components/ProductPricing/ProductPricing.tsx index 153ec3fd2..0c53611db 100644 --- a/src/products/components/ProductPricing/ProductPricing.tsx +++ b/src/products/components/ProductPricing/ProductPricing.tsx @@ -37,6 +37,12 @@ const ProductPricing: React.FC = props => { const formErrors = getFormErrors(["basePrice"], errors); + const handlePriceChange = event => { + if (/^\d*(\.\d+)?$/.test(event.target.value)) { + onChange(event); + } + }; + return ( = props => { name="basePrice" value={data.basePrice} currencySymbol={currency} - onChange={onChange} + onChange={handlePriceChange} InputProps={{ inputProps: { min: 0 diff --git a/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx b/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx index d39a927b0..d8092219c 100644 --- a/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx +++ b/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx @@ -36,6 +36,12 @@ const ProductVariantPrice: React.FC = props => { const formErrors = getFormErrors(["price", "cost_price"], errors); + const handlePriceChange = event => { + if (/^\d*(\.\d+)?$/.test(event.target.value)) { + onChange(event); + } + }; + return ( = props => { })} value={price} currencySymbol={currencySymbol} - onChange={onChange} + onChange={handlePriceChange} disabled={loading} + InputProps={{ + inputProps: { + min: "0" + } + }} />
@@ -76,8 +87,13 @@ const ProductVariantPrice: React.FC = props => { } value={costPrice} currencySymbol={currencySymbol} - onChange={onChange} + onChange={handlePriceChange} disabled={loading} + InputProps={{ + inputProps: { + min: "0" + } + }} />