Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ Returns the props to apply to the **CVC** input.

Returns the props to apply to the **ZIP** input.

Pass `allowCanada` as prop to `getZIPProps` to allow for letters used in Canadian postal codes.

**IMPORTANT:** You must place your event handlers (e.g. `onChange`, `onBlur`, etc) inside the `getZIPProps()` so the default event handlers in React Payment Inputs don't get overridden.

##### Example snippet
Expand Down
4 changes: 2 additions & 2 deletions src/usePaymentInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export default function usePaymentCard({
props.onKeyPress && props.onKeyPress(e);

if (e.key !== utils.ENTER_KEY_CODE) {
if (!utils.validator.isNumeric(e)) {
if (!props.allowCanada && !utils.validator.isNumeric(e)) {
e.preventDefault();
}
}
Expand All @@ -432,7 +432,7 @@ export default function usePaymentCard({
maxLength: '6',
name: 'zip',
placeholder: 'ZIP',
type: 'tel',
type: props.allowCanada ? 'text' : 'tel',
[refKey || 'ref']: zipField,
...props,
onBlur: handleBlurZIP(props),
Expand Down