ограничение на ввод букв на числовом инпуте
This commit is contained in:
parent
5a7697c5aa
commit
bc48cc0c33
@ -45,7 +45,7 @@ export default function CreateTariff() {
|
|||||||
const checkFulledFields = (values: Values) => {
|
const checkFulledFields = (values: Values) => {
|
||||||
const errors = {nameField: "", amountField: "", privilegeIdField: ""} as any;
|
const errors = {nameField: "", amountField: "", privilegeIdField: ""} as any;
|
||||||
// values.nameField = "aa"
|
// values.nameField = "aa"
|
||||||
// values.amountField = "aa"
|
values.amountField = String(Number(values.amountField.replace(/[^0-9]/g,"")))
|
||||||
|
|
||||||
if (values.nameField.length === 0) {
|
if (values.nameField.length === 0) {
|
||||||
errors.nameField = "Пустое название тарифа"
|
errors.nameField = "Пустое название тарифа"
|
||||||
@ -225,20 +225,14 @@ export default function CreateTariff() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Field
|
<OutlinedInput
|
||||||
as={OutlinedInput}
|
id="amountField"
|
||||||
id="tariff-amount"
|
|
||||||
type="number"
|
|
||||||
variant="filled"
|
|
||||||
name="amountField"
|
name="amountField"
|
||||||
|
onChange={(e) => props.handleChange(e.target.value)}
|
||||||
|
value={props.values.amountField}
|
||||||
label="Кол-во единиц привилегии"
|
label="Кол-во единиц привилегии"
|
||||||
error={props.touched.amountField && !!props.errors.amountField}
|
type="number"
|
||||||
helperText={
|
/>
|
||||||
<Typography sx={{ fontSize: "12px", width: "200px" }}>
|
|
||||||
{props.errors.amountField}
|
|
||||||
</Typography>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Field
|
<Field
|
||||||
as={OutlinedInput}
|
as={OutlinedInput}
|
||||||
id="tariff-custom-price"
|
id="tariff-custom-price"
|
||||||
|
Loading…
Reference in New Issue
Block a user