user56690
user56690

Reputation: 259

angularJs check if input is entered

I am new to angular Js and developing a form where the input box will minimize when input is being entered. i am using ng-blur,ng-click and ng-focus and calling the function which will change the css classes for this purpose. But the issue is when id/password is saved, the css class is not changed as their is no click,focus,blur on the form.

Below is the code snippet

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

How can the id/password that is saved be recognized?

Thanks in advance.

Upvotes: 1

Views: 455

Answers (1)

CrazyMac
CrazyMac

Reputation: 462

I think you can use something like below assuming loginform as the form name and username as your name for userID field

            <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>

Upvotes: 2

Related Questions