What is the efficient way to validate a form in iPhone? Basic validation like if the all required textFields are filled and some validation for email and phone.
- Is there way to show all the error once the submit button clicked? (I’m basically highlighting the textField red)
Any help?
You could actually show the validation before the submit button has been tapped, by using the
UITextFielddelegate methods.So to achieve this you would just use the
textFieldDidEndEditingdelegate method (documented here) to detect when the user had moved from one text field to another, and then you could immediately highlight a field red if it didn’t pass your validation test.This is a nice approach, because the user immediately knows their input won’t be accepted, which can save time and frustration.
There are obviously lots of different approaches to your question, so it’s really a matter of visual preference and/or style, but definitely consider doing ‘in-line’ validation as described above.