angularJs检查是否输入

angularJs check if input is entered

本文关键字:输入 是否 检查 angularJs      更新时间:2023-09-26

我是角Js的新手,并且正在开发一种在输入时输入框将最小化的表单。我正在使用ng-flur、ng-click和ng-focus,并调用将为此目的更改css类的函数。但问题是,当保存id/password时,css类不会更改,因为它们在表单上没有点击、聚焦、模糊

以下是的代码片段

<input  class="field"  name="id"  ng-model="form.id"
        ng-click="onClickFunction()" ng-focus="onFocusFunction()"
        ng-blur="onBlurFunction(fieldValue)" type="text" required> 

如何识别保存的id/密码?

提前谢谢。

我认为您可以使用以下内容,假设loginform为表单名称,username为userID字段的名称

            <input id="login_username" class="form-control" type="text" ng-minlength="5"
                name="userName" placeholder="Username" ng-model="userName" required
                autofocus>
            <div style="color: red" ng-messages="loginForm.userName.$error" ng-if="loginForm.userName.$dirty">
                <div ng-message="required">This field is required</div>
                <div ng-message="minlength">Username should be over 5 characters</div>
            </div>