feat(filters): Eingabevalidierung für IntFilter hinzufügen, um nur numerische Werte zuzulassen
This commit is contained in:
parent
55ba6031eb
commit
0eef478a41
@ -1,3 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
import TextField from '@mui/material/TextField';
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@ -5,13 +7,20 @@ type BoolFilterProps = {
|
||||
label: string;
|
||||
}
|
||||
|
||||
const isNumbers = (str: string) => /^[0-9]*$/.test(str);
|
||||
|
||||
export function IntFilter({ label }: BoolFilterProps) {
|
||||
const [val, setVal] = useState("");
|
||||
|
||||
const onInputChange = (event: any) => {
|
||||
const value = event.target.value;
|
||||
if (isNumbers(value)) {
|
||||
setVal(value);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<TextField
|
||||
type="number"
|
||||
label={label}
|
||||
variant="standard"
|
||||
/>
|
||||
<TextField label={label} value={val} onChange={onInputChange} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user