for now the type = "number" in TextFiled Material-UI
accept number(0-9) coma (,) and double dash(--)
and, I just need one dash(-)
I've seen to insert pattern in inputProps, but it seems not working..
Any help is greatly appreciated
Thank you
<TextField
label="Super Koin"
variant="outlined"
type="number"
inputProps={{
pattern: /^-?\d+(?:\.\d+)?$/g
}}
name="Gajian"
style={{ marginBottom: "22px" }}
defaultValue={
(form.injectCustomer && form.injectCustomer.supercoin) ||
0
}
fullWidth
inputRef={this.superPoints}
InputLabelProps={{
shrink: true
}}
onChange={e => {
this.actionRow(
{ key: "supercoin", value: (e.target.value)},
"supercoin"
);
}}
/>
I'm trying to make validation inside onChange
onChange={e => {
console.log(e.target.value,"EEE")
this.actionRow({
key: "supercoin",
value: e.target.value === "--" ? e.target.value = 0 : e.target.value =
},
"supercoin"
);
}}
but, the console.log for "-" and "--" is empty and it seems impossible to validate from onChange