1

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.

2
  • 2
    I guess you are looking for .ng-dirty class Commented May 6, 2016 at 10:14
  • Your question is not clear. Explain more Commented May 6, 2016 at 10:17

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for this but autofocus would always minimize the field. i want it to be minimized if the input is auto-entered only..(by id/pass save in browser)
When you say minimize, do you mean to get off from the highlighted textbox or something else here ?
i am having css classes which will minimize the field when the user is entering the input. I am using ng-focus, ng-blur, ng-click for changing the css classes. when the user has finished entering the text 'Password' stays in minimized state, if nothing is entered then it comes back to its original state
Can you share your complete code or put it in plunkr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.