Let's say I have a numeric password field, essentially a PIN:
[DataType(DataType.Password)]
public int Password { get; set; }
and then attempt to submit an alphabetic password, then the validation will fail on the server (as expected), but displays The value 'foo' is not valid for Password. to the user.
Is there any way to avoid displaying the attempted password? Or am I thinking about this wrong?
I could just make the field a string and validate it otherwise, but I'm not sure I like that solution, and was hoping there was something else I'm overlooking.
I could just make the field a string and validate it<-- i like it. Could you elaborate why you don't? to me it seems the in built data valiation doesnt do exactly what you want so you have to code something yourself - perfectly acceptable. Also given the password is not acceptable what is your issue with displaying it?so you have to code something yourselfYou're right, I'm just being stupid, but my issue with it wasn't not wanting to write it myself, rather that I was caught up on the fact that it's a number so it "should" be modeled as an int.[DataType(DataType.Password, ErrorMessage = "Not a valid password")]