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

is there any options to Disallow some special characters in input when type? #344

Closed
gopinath-sixt opened this issue May 4, 2018 · 7 comments

Comments

@gopinath-sixt
Copy link

Version

^3.1.2

Steps to reproduce

user typing the text|numeric|some special chararter in asynctypeahead input component and getting dropdown value perfectly. Validating the entered text|numeric|some special chararter through InputChange.

Expected Behavior

Some options for special character shouldn't be allow to enter in input.

Actual Behavior

There is no restriction.

@ericgio
Copy link
Owner

ericgio commented May 4, 2018

This seems like a duplicate of #230, but please reopen if you feel I'm misunderstanding something.

@ericgio ericgio closed this as completed May 4, 2018
@ericgio
Copy link
Owner

ericgio commented May 4, 2018

Seems also related to #33

@gopinath-sixt
Copy link
Author

Hi @ericgio ,

When i type the text, it will upate the value in state.query in Typeahead Component and i will update this value by setState({myVar:value}) in my component through InputChange. I will check these special characters (@$%^) found in myVar, if true, then ill remove the special characters from myVar and i need to update this value in Typeahead state.query.

I am validating the value only when type and not in selecting the dropdown.

I can update the modified value in myVar but i can't update in query. Any solution,please.

@ericgio
Copy link
Owner

ericgio commented May 4, 2018

You can modify the query when you get it from your onSearch method. Unfortunately, you can't update the input text directly.

@gopinath-sixt
Copy link
Author

gopinath-sixt commented May 7, 2018

Hi @ericgio ,

onKeyDown={(e) => {
  var a = e.key;
  if (SPECIAL_CHARACTERS_VALIDATOR.indexOf(a) > -1) {
    e.preventDefault();          
  }
}}

and yes disallowing key typed... Cheers!!!

@ericgio
Copy link
Owner

ericgio commented May 7, 2018

@gopinath-sixt: Just so I understand, did the above code solve your problem, or is it just an example of what you're trying to achieve?

@gopinath-sixt
Copy link
Author

@ericgio yeah working fine

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