Verify UITextField

I have a UITextField in my application created in IB. I need to check the same. that is, it must be a number from 2 to 20

What is the best way to conduct an audit; through the code OR can it be completely controlled from IB?

Please let me know how to check the field.

+4
source share
1 answer

You cannot verify this from Interface Builder.

Try something like this. After the textField initialization, put the Value Changed handler as follows:

 [textField addTarget:self action:@selector(validateField:) forControlEvents:UIControlEventEditingChanged ]; 

Then write the message as follows:

 - validateField:(id)sender { // put validation code here } 
+10
source

Source: https://habr.com/ru/post/1339546/


All Articles