Knockout validation on my dropdown don't work

后端 未结 3 708
粉色の甜心
粉色の甜心 2021-01-07 01:26

I work on a asp.net mvc project with the durandal template + breeze.

I would like to define validation logic on my view for adding/editing operations.

So far

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 01:57

    When you say "clear the dropdown", how can an option be not picked when there are only three options. Could you make the first dropdown item "Choose an item..." so that you know there will always be one item. If the dropdown index is 0, then show your red error message.

    Another option would be to show the red error message if the selectedindex is 0 or the itemcount is 0.

    Does that help?

提交回复
热议问题