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

Restricting input to only letters. #33

Closed
vhellem opened this issue Jul 14, 2016 · 8 comments
Closed

Restricting input to only letters. #33

vhellem opened this issue Jul 14, 2016 · 8 comments
Assignees
Milestone

Comments

@vhellem
Copy link

vhellem commented Jul 14, 2016

Hi.

Any idea on how i could restrict the input to this component to be only letters? So far i have tried connecting it to a redux-form-field that is hooked up to a reducer to remove all fields that are not letters.

TypeAhead selected={reduxField.value? [{name: reduxField.value}]: []} onInputChange={value=> reduxField.onChange(value)}

However, I am still able to write in digits in the textfield, although they will get deleted as soon as i type in a valid character it seems a bit odd to me. Any idea on how i could completely restrict the input to the textfield?

@ericgio ericgio added this to the v1.0.0 milestone Jul 18, 2016
@ericgio ericgio self-assigned this Jul 18, 2016
@ericgio
Copy link
Owner

ericgio commented Jul 18, 2016

Unfortunately there's no way to do this at the moment and it's not something I plan on supporting in the current API. My goal with v1.0 is to provide a much more flexible API that allows developers much more control over the individual pieces of the component, including this use case. I don't currently have a timeline for when I'll release that yet, however.

@vhellem
Copy link
Author

vhellem commented Jul 21, 2016

I managed to workaround the issue by adding a function prop to the component that reduces the input change to only contain valid letters. Would be open to a PR on the new functionality?

@ericgio
Copy link
Owner

ericgio commented Jul 21, 2016

This feels like a pretty specific use-case to me, so I'd prefer not to support it in the current API and instead make the component more flexible as mentioned above. Thanks for raising the issue and offering to submit a PR, though.

@Jock924491
Copy link

Jock924491 commented Jul 26, 2016

There is on thing to consider though, is things like zip code search. We only want 5 numeric values. There could be a regex/function for input verification

@ericgio ericgio changed the title Restricting input to to only letters. Restricting input to only letters. Jul 28, 2016
@ericgio
Copy link
Owner

ericgio commented Jul 31, 2016

Do you mind posting an example of how you'd do it with a raw text input?

@Jock924491
Copy link

For a react module, I'd create a inputValidation property & if present on text change verify that the input matched the validation (I'd use regex personally). There is also an argument for a masked input usage though as it's clearer for the user to see.

@ericgio
Copy link
Owner

ericgio commented Aug 1, 2016

Could you use onInputChange and validate inside that?

@ericgio ericgio removed this from the v1.0.0 milestone Nov 29, 2016
@ericgio ericgio mentioned this issue May 11, 2017
@ericgio ericgio added this to the 2.0 milestone Jul 20, 2017
@ericgio
Copy link
Owner

ericgio commented Jul 21, 2017

Closing this out in favor of the broader #79, which should address this use-case. The addition of inputProps in v2.0.0-alpha.1 will hopefully solve this issue.

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

No branches or pull requests

3 participants