Modal dialogs sometimes called alerts on mobile.
They should be generally used for communicating something important to the user. Informing users of errors in modal dialogs or alerts is not a good idea for one big reason. The dialog content is not easily accessible. Once you dismiss it, it’s not there anymore, and it’s not usually clear how to get it back.
Let’s take an example. The invalid password.
Your password needs to be at least eight characters including a lower case letter, upper case letter, a number, and a special character. The error appears in a dialog that must be dismissed to fix the problem. But, once I dismiss the dialog, I lose all the information about how the error must be fixed. The error fields are not even highlighted.
Even if I can recall that my password was wrong, I may not be able to remember all the different constraints that it had to satisfy. Was it one or two capital letters? And special characters? Especially on mobile where interruptions are frequent, it’s easy for people to forget even the simplest instruction.
If I look away from my screen for one minute, by the time I come back I might have forgotten even what I was trying to do, to say nothing about which field was wrong and what the password requirements might have been.
If users have to follow any instructions contained in the alert, they will need to memorize them. And that goes against one of the 10 usability heuristics.
Favor recognition over recall. When you ask people to recall information, you’re asking them to work harder.
The solution is simple.
Instead of showing the error in a dialog, simply mark the error field and show the error next to it, so people can easily refer to it as they’re fixing the problem.
Reference: https://www.nngroup.com/videos/mobile-error-handling-alerts/