Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:53:51+00:00 2026-06-04T20:53:51+00:00

How to allow only certain characters in UITextView? I want to allow only English

  • 0

How to allow only certain characters in UITextView?

I want to allow only English characters & numbers & Arabic characters.

I found many solutions but for UITextField not UITextView!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:53:53+00:00Added an answer on June 4, 2026 at 8:53 pm

    You can use the textView:shouldChangeTextInRange:replacementText: method of the UITextViewDelegate (docs):

    The text view calls this method whenever the user types a new
    character or deletes an existing character. Implementation of this
    method is optional. You can use this method to replace text before it
    is committed to the text view storage. For example, a spell checker
    might use this method to replace a misspelled word with the correct
    spelling.

    You should check if the replacementText parameter contains illegal characters. In that case you can return NO to prevent the text from being inserted. This might give problems when a text of more than one character is inserted, and not all characters are allowed: what do you do, allow the insertion (including the illegal characters) or prevent it (including the allowed characters)?


    This means you need the textViewDidChange: method (docs):

    The text view calls this method in response to user-initiated changes
    to the text. This method is not called in response to programmatically
    initiated changes.

    When this method is called you could check the value of the UITextView and remove illegal characters afterwards.


    I think it would be best to use both methods. The first one gives the best experience when the user is typing (the character is not displayed at all, instead of first being displayed and later being removed). The second method makes sure that illegal characters will be removed if some text is pasted, for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to allow only English characters to be typed in my asp:TextBox (in
I have the following code which will allow only numbers 0-9. But i want
I want to allow users only to type certain characters based on the a
I want to extend Ion Auth to only allow certain email addresses to register.
I found this snippet that says will only allow certain file types. Will it
I need to validate a textbox that it should allow only certain characters and
Possible Duplicate: How can I only allow certain filetypes on upload in php? i'm
Is it possible to allow only letters or numbers in a string in java
I would like to allow only one country access, but exclude proxies within this
I want to check a string to allow only a-z A-Z 0-9 . /

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.