输入字段不变时如何使用ng-show显示消息?

How to display the message using ng-show when the input field is not changed?

提问人:Ishmeet Singh 提问时间:1/22/2021 最后编辑:Ishmeet Singh 更新时间:1/22/2021 访问量:238

问:

Hy 我在名为 relationshipForm 的表单中有一个输入。

<input id="change_R_text" type="text" class="form-control" 
                               ng-model="formData.parameters.otherRelationshipText"
                               ng-pattern="/^[a-zA-Z. ]+$/"
                               ng-required="true" name="otherRelationshipText" maxlength="100">

如果输入中的内容未更改,我想显示一条消息

我正在使用它来显示所需验证的消息

                            <span style="color:red" ng-show="relationshipForm.$sumbitted && relationshipForm.otherRelationshipText.$error.required">  field cannot be empty </span>

现在,如果用户尝试更新输入框而不使用相同的跨度结构更改任何内容,我想显示消息......这是消息“您无法更新相同的选定字段”... 。如何修改以下跨度?

<span style="color:red" ng-show="relationshipForm.$sumbitted && _________   ">  you cant update the same selected field </span>

如何更新我的 ng-show 条件?

angularjs 验证 ng-show

评论


答:

0赞 Kristof Czimer 1/22/2021 #1

您是否尝试过使用 ng-change 指令?https://www.w3schools.com/angular/ng_ng-change.asp

评论

0赞 Ishmeet Singh 1/22/2021
Hy 还有其他选择吗?