iphone - How to set the character limit limit in three UITextfield -


this question has answer here:

i have 3 textfield.

1.textfield1 = 15 charecter

2.textfield2 = 50 charecter

3.textfield3 = 50 charecter

code snippet

if (textfield1 .text.length <15 && textfield2 .text.length <50 && textfield3 .text.length <50) {

    return yes;              }else{          return no;     } 

how set limit of 3 uitextfield.

thanks in advance

try this,

- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string{     nsuinteger length = [textfield.text length] + [string length] - range.length;      if([textfield  isequal:textfield1])     {         if(length<15)             return yes;         else             return no;         nslog(@"1");     }     else  if([textfield  isequal:textfield2] | [textfield  isequal:textfield3])     {         if(length<50)             return yes;         else             return no;         nslog(@"2 or 3");      }   } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -