I recently logged in my Microsoft account with my 25 characters password and saw this:

The only reasonable reaction I could have was: "WTF! Are they out of their mind to ask me to shorten the password instead of using maxlength property? What's next? Maybe it will ask me to compute the password hash by hand too? Or maybe I would tell myself to the app if my password is correct?"
But after all, there must be a valid reason for such thing. They can't just do it in a such terrible way without any reason.
What is the reason to inform the user that the password is limited to N characters when the actually entered password is longer, instead of silently trimming the password?