MVC Razor Validation Errors showing on page load when no data has been posted

前端 未结 4 1467
暖寄归人
暖寄归人 2020-12-09 16:03

I\'m messing around with data annotations. When I click on a link to go to a page, the validation messages are being displayed, but I would like to have the validation messa

4条回答
  •  -上瘾入骨i
    2020-12-09 16:47

    .field-validation-valid {
      display: none;
    }
    

    Whenever the validation triggers on page load, this ".field-validation-valid" value is automatically added to the class attribute of the triggered input element.

    By adding CSS to display none as that particular class's value, you'll no longer see the validation messages on initial page load.

    The validation messages will still display normally after the particular input element has been touched.

提交回复
热议问题