In our mobile applications (intended for Android and iOS platforms), we have fields that should be filled by users.

If the user fills the field not in required format what should I do

  1. show the validation message and empty the field, or
  2. show the validation message and leave the field as the user initially filled it, letting him edit his old records?

4 Answers 4


Typing on mobile is a very arduous and unpleasant process, so we should try keeping it to a minimum.

Sometimes your users will have made just a small error that can be fixed by replacing or adding a character or two (typically they typed something instead of @ in an email address etc.). Sometimes they will have made a big error and they need to retype the whole thing. So unless you have a way of knowing or making an educated guess as to which type of error will be more common with your users and your type of data - it seems like there's no way of knowing. However, small mistakes are much more common by nature.

Even if we say that we have no way to know this, deleting an entire field on mobile is still much easier for the user than entering an entire field - you just hold the Delete key. So if we keep the data, those who would've preferred that we clear the field have a small price to pay for our decision, since the field is deleted easily. But if we clear the data, those users who would've preferred that we keep it, have a high price to pay - they need to retype everything.

Seems to me that keeping the data is definitely the safer way to go.

  • 22
    It's also good to show them what they had so they don't make the same mistakes twice.
    – UXerUIer
    Aug 26, 2014 at 13:29
  • 20
    Also true for non-mobile. Aug 26, 2014 at 13:31
  • 1
    With touch, you don't even need to hold the delete key on some devices/browsers - I can long-press the field and "clear all"
    – Izkata
    Aug 26, 2014 at 14:09
  • 9
    Exception: password fields (where you don't see what you typed anyway). And fields that the user should type in twice to ensure correctness (I'd suggest to maybe keep one and clear the other). And of course captchas ;) Aug 26, 2014 at 15:42
  • 4
    @sapi. Clearing passwords is a security concern: The incorrect password is probably only slightly incorrect, or is a password for another account. The server should never publish passwords, so the new copy of the page should not contain the password. (This may not apply if the validation is done client side or with Ajax.)
    – TRiG
    Aug 27, 2014 at 13:59

From a usability point of view, definitely keep their entry. There is nothing more annoying to users, in our experience, than clearing their entry on failing validation. They need to be able to see what they have done wrong, and if you clear it they are having to use their memory.

  • 8
    Definitely true on non-mobile platforms as well. Aug 26, 2014 at 13:32

Why not provide a way for user to do both ? Data can be left intact as suggested by others and providing a small "X" button/icon ( similar to the magnifying glass icon usually seen in search boxes) at the end of text box to clear the whole thing if the user intends to.

  • Said small X button should preferably be very near the magnifying glass. Also, no need for a confirmation prompt. Also, disable form submit from keyboard. Users still have a 50% chance of doing the action they intended to. Aug 30, 2014 at 14:08

Generally speaking, especially for text type input or textarea field, it is better to keep the existing text upon validation error. However, depending on your actual scenario, there may be other decision making steps that you might need to consider:

  • If it is in a totally wrong format. Example you requested for numbers and the user fills up the field with alphabets, clear it and show error message. It is meaningless to keep input that you do not want to accept.
  • If it is in a partially wrong format. Example you want users to enter a description about themselves, but clearly stated that URLs are not accepted, remove any URLs programmatically and save the input without showing any error message.
  • If it contains sensitive information. Example user entered a wrong password. Clear it and show error message upon authentication failure.
  • If you detect abnormal inputs such as extra POST parameters, clear the form but do not show any error message. If possible, redirect user to another page or log out the user.
  • "remove any URLs programmatically" -- never modify user input behind their back. Especially not when that involves content deletion. Especially not if you think object.cx is a URL rather than a piece of code. Aug 30, 2014 at 14:10
  • "If you detect abnormal inputs such as extra POST parameters, clear the form but do not show any error message. If possible, redirect user to another page or log out the user." - Bad. Bad. Bad. How ever will I debug my app that's trying to interface with your app now? Unless, of course, you don't like my app trying to submit a form. Aug 30, 2014 at 14:12
  • @JanDvorak, for URL detection, I tend to use a more stringent regex to minimize false positives like the one you pointed out. In the real world, there is always a trade-off between security and usability. Of course, this site is all about UX and I digressed. Aug 31, 2014 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.