I want to clear the submitted value of a field in a model if the ModelState
shows that the field is not valid.
This is where I have got so far but can't tie up the key to value in the model. Any suggestions?
if (!ModelState.IsValid)
{
foreach (string key in ModelState.Keys)
{
if (!ModelState.IsValidField(key))
{
// This field is not valid so set to empty string in model
// Something like....
model[key] = "";
}
}
}