html5 input pattern for some characters

Dear Experts,

How can I prevent my users entering ç,ı,Ş,ş,Ç these characters into my text box?
what pattern should I use?
I'm using html5

<input type="text" name="test" id="test">
LVL 1
BRMarketingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Are you referring to using the input pattern attribute or do you want to actually prevent those char's from even displaying - i.e. use a JavaScript keydown function to cancel the event if it is one of those characters?
1
BRMarketingAuthor Commented:
Dear Julian,
JavaScript keydown function would be great? how can I do that?
how can I my users do not enter Ç,ş,ğ characters?
0
BRMarketingAuthor Commented:
can I also use html input pattern regex for preventing this?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

BRMarketingAuthor Commented:
I can also use a php replace function to change the characters...
what do you suggest I should do?
0
Julian HansenCommented:
can I also use html input pattern regex for preventing this
No, the support cross browser varies and for the most part it just highlights the error - it does not prevent the entry of the characters.

What you want to do is intercept the entry of the character and prevent it even showing.

This is fairly straight forward for characters typed in but what about cut and paste - how do you want that handled.

Two options
1. Any change to the input you remove unwanted characters - this might end up with bad data anyway because you will be removing the option for the user to correct and assume that what they wanted was the word without the invalid characters
2. Don't worry about replacing - rather just highlight the input as being invalid and prevent submission until the user fixes the problem.

You will still need to validate on the PHP side as nothing from the browser can be trusted anyway - client side validation does not negate the need for server side validation - the latter is ALWAYS needed - the former - implement for convenience as required.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BRMarketingAuthor Commented:
Thank you Julian
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.