久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

iOS UITextField 中的密碼驗證

Password validation in UITextField in iOS(iOS UITextField 中的密碼驗證)
本文介紹了iOS UITextField 中的密碼驗證的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我的 iPhone 應用程序中有 1 個 UITextfield 用于密碼.

I have 1 UITextfield for password in my iPhone application.

我想通過以下驗證來驗證此文本字段.

I want to validate this textfield with the following validation.

  • 必須至少為 10 個字符
  • 必須至少包含一個小寫字母、一個大寫字母、一個數字和一個特殊字符
  • 有效的特殊字符為 – @#$%^&+=^.*(?=.{10,})(?=.*d)(?=.*[az])(?=.*[AZ])(?=.*[@#$%^&+=]).*$

如何限制 UITextField 滿足上述要求?

How can I restrict the UITextField with above requirements?

推薦答案

我會這樣做.驗證應該在用戶輸入密碼時完成,而不是在兩者之間.我不會使用 NSRegularExpression.

This is how I would do it. The validation should be done at the end when the user has typed in the password and not in between.I will not be using NSRegularExpression.

-(void)textFieldDidEndEditing:(UITextField *)textField{
   int numberofCharacters = 0;
   BOOL lowerCaseLetter,upperCaseLetter,digit,specialCharacter = 0;
   if([textField.text length] >= 10)
   {
      for (int i = 0; i < [textfield.text length]; i++) 
      {
         unichar c = [textfield.text characterAtIndex:i];
         if(!lowerCaseLetter)
         {
           lowerCaseLetter = [[NSCharacterSet lowercaseLetterCharacterSet] characterIsMember:c];
         }
         if(!upperCaseLetter)
         {
           upperCaseLetter = [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:c];
         }
         if(!digit)
         {
            digit = [[NSCharacterSet decimalDigitCharacterSet] characterIsMember:c];
         }
         if(!specialCharacter)
         {
            specialCharacter = [[NSCharacterSet symbolCharacterSet] characterIsMember:c];
         }
      }

      if(specialCharacter && digit && lowerCaseLetter && upperCaseLetter)
      {
         //do what u want
      }
      else
      { 
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                        message:@"Please Ensure that you have at least one lower case letter, one upper case letter, one digit and one special character"
                                                       delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
      }

   }
   else
   {
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                        message:@"Please Enter at least 10 password"
                                                       delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
   }
}

希望這會有所幫助...

Hope this helps...

這篇關于iOS UITextField 中的密碼驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to set Edittext view allow only two numeric values and two decimal values like ##.##(如何設置 Edittext 視圖只允許兩個數值和兩個十進制值,如 ##.##)
Android : How to set acceptable numbers and characters in EditText?(Android:如何在 EditText 中設置可接受的數字和字符?)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
Validation on Edit Text(驗證編輯文本)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態和動態單元格中處理單元格選擇)
主站蜘蛛池模板: 91精品国产一区二区三区香蕉 | 国产欧美一区二区三区久久 | 日本人麻豆 | 日日摸天天添天天添破 | 一区二区中文字幕 | 欧美一级免费 | 黄色一级大片在线免费看产 | 欧美一区二区激情三区 | 最新日韩在线 | 999久久久 | 亚洲一级毛片 | 婷婷丁香综合网 | 成年人在线电影 | 精品久久不卡 | 高清色视频 | 成人在线影视 | 天天干天天干 | 欧美一区二区三 | 久久99久久98精品免观看软件 | 成年人在线观看视频 | 国产精品精品视频一区二区三区 | 金莲网| 日韩欧美在线观看 | 亚洲一区二区在线 | 日韩一区二区三区四区五区 | 波多野结衣中文视频 | 一区二区三区影院 | 欧美成人不卡 | 欧美在线亚洲 | 国产四区 | 国产精品亚洲第一 | 91社区在线高清 | 国产一区二区不卡 | 欧美aaa级 | 亚洲国产视频一区二区 | 成人国产午夜在线观看 | 久久久五月天 | 91精品久久久久久久久中文字幕 | 中文字幕日韩专区 | 亚洲一本| 亚欧洲精品在线视频免费观看 |