ios - How do I detect if a text field has text in it rather than a numerical value? -


I have a text field that enters the user number and turns it into an integer.

The keyboard set is one of the decimal number and the paste function is still enabled, even though the user can paste text into it.

I want to set it to change a label on "Error" if the user enters a numeric value in it.

I do not want to disable the paste function because I still want the user to have the ability to copy and paste their numerical values ​​in their app.

If you want to apply the restriction only enter numeric values, then UITextField

  - (BOOL) textField: (UITextField *) textField shouldChangeCharactersInRange: (NSRange) Category Replacement String: (NSString *) string {NSCharacterSet * nonNumberSet = [[ NSCharacterSet decimalDigitCharacterSet] invertedSet]; Return ([string string bitimeter converter inset: non-numberet]. Length = gt;) || [String avastostring: @ ""]; }   

If the string is numeric, then no

yes EDET:

Adam's answer is best for check text, only numeric or not.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -