Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I'm trying to make example from this article using angular+bootstrap. I have this working code:

<div ng-controller="Ctrl">
    <br>
    <hr>

    <form name="signup_form" novalidate ng-submit="signupForm()">
        <fieldset>
            {{' signup_form.submitted \''+signup_form.submitted+ '\' ' }}<br>
            {{' submitted \''+submitted+ '\' ' }}<br>
            {{' $scope.signup_form.$valid \''+signup_form.$valid+ '\'' }}

            <div class="control-group" ng-class="{error: signup_form.name.$dirty && signup_form.name.$invalid}">
                <legend>Signup</legend>
                <div class="row">
                    <div class="span12">
                        <label>Your name</label>
                        <input type="text"
                               placeholder="Name"
                               name="name"
                               class="error"
                               ng-model="signup.name"
                               ng-minlength=3
                               ng-maxlength=20 required/>
                    </div>
                </div>
            </div>
            <button type="submit" class="button radius">Submit</button>
        </fieldset>
    </form>

</div>

http://jsfiddle.net/cQ324/2/

The questions are:

  1. This piece of code:

    <div class="control-group" ng-class="{error: signup_form.name.$dirty && signup_form.name.$invalid}">
    

    does not look very nice. I feel it's not good practice to do it this way. How could it be more easy and correct?

  2. If I press input field, I instantly got red borders. I found this problem, but it is a very old thread. What's the best and correct way to avoid this red box on empty field click?

Any overall code suggestions are welcome.

share|improve this question
    
on point 2 (I found the Fiddle my bad) when I looked at it in chrome when I typed in my name it instantly showed a blue border, letting me know that what I typed was a good input, the red border is probably what it is programmed to do when the input is invalid, and it looks like it does this live, on-the-fly. I think that is supposed to be what it does. you would have to change the JavaScript to change that functionality, or have it run on the button click somehow –  Malachi Oct 11 '13 at 13:25
1  
This question appears to be off-topic because it is code straight from a tutorial and you are asking us to solve a bug/inconsistent behavior you found. –  konijn Apr 8 at 10:42
add comment

closed as off-topic by konijn, rolfl Apr 8 at 11:06

  • This question does not appear to be a code review request within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.