Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expiry date don't format input data #41

Open
carloscba opened this issue Jul 2, 2020 · 1 comment
Open

Expiry date don't format input data #41

carloscba opened this issue Jul 2, 2020 · 1 comment

Comments

@carloscba
Copy link

carloscba commented Jul 2, 2020

I'm working with react-payment-inputs and material ui:

const { meta, getCardNumberProps, getExpiryDateProps, getCVCProps, getCardImageProps } = usePaymentInputs();
const { erroredInputs, touchedInputs } = meta;

...

const [expiryDate, setExpiryDate] = useState();
const handleChangeExpiryDate = (event) => setExpiryDate(event.target.value);

...

<TextField
  inputProps={{ "data-testid": "expireDate" }}
  {...getExpiryDateProps({ onChange: handleChangeExpiryDate })}
  defaultValue = { expiryDate }
  error={ (erroredInputs.expiryDate && touchedInputs.expiryDate) ? true : false } 
  helperText= { (touchedInputs.expiryDate) && erroredInputs.expiryDate }
  label="Expiry Date"
  type="text"
  margin="dense"
  fullWidth
/>                                

In this example validation work fine but don't format the input date as 00/00

Screenshot Capture - 2020-07-02 - 12-49-12

If I implement a simple input everything it's ok

<input {...getExpiryDateProps({ onChange: handleChangeExpiryDate })} value={expiryDate} />

Saludos, muchas gracias.

@kguptaaa
Copy link

kguptaaa commented May 7, 2021

Hi,
You need to pass the getter method to inputProps like this:

<TextField
  inputProps={getExpiryDateProps({ onChange: handleChangeExpiryDate })}
  defaultValue = { expiryDate }
  error={ (erroredInputs.expiryDate && touchedInputs.expiryDate) } 
  helperText= { (touchedInputs.expiryDate) && erroredInputs.expiryDate }
  label="Expiry Date"
  type="text"
  margin="dense"
  fullWidth
/> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants