search

Home  >  Q&A  >  body text

textfield input string filtering - objective-c - textfield input string filtering

Filter the string when inputting in textField. Only Chinese characters can be input, and no other input is allowed

伊谢尔伦伊谢尔伦2792 days ago697

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-05-02 09:29:53

    During the input process, I first use regular expressions to determine whether the input is Chinese. If it is Chinese, assign it to textfiled.text, and then store this value in a global variable. Later, when textfiled.text changes, if there is a non-Chinese character Characters, use the previously stored global variables to intercept the string, and only the Chinese string is assigned to textfiled.text, so that textfiled can only input Chinese during the input process.

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-02 09:29:53

    You can judge the text in the proxy method. If there are English numbers, just delete them

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-02 09:29:53

    This may not be possible, because when typing Chinese pinyin before finishing typing, the English words will be displayed. If there are non-Chinese characters in the construction, the save button will be grayed out, and the user will be prompted to delete the non-Chinese characters.

    reply
    0
  • Cancelreply