Take the 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
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.