Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Angular Basics Angular Form Validation HTML5 Input Rules

Michael Strand
Michael Strand
10,897 Points

Required attribute isn't working on form inputs

Below is my snippet from following along. I'm running Angular 7 and viewing in Firefox 67.0.4 and when I click submit it doesn't show the in browser validation error. It will still add a blank comment.

<form (submit)="onSubmit()" #commentForm="ngForm">
    <div>
        <label for="name">Name</label>
        <input type="text" name="name" [(ngModel)]="name" required />
    </div>
    <div>
        <label for="comment">Comment</label>
        <textarea name="comment" [(ngModel)]="comment" required ></textarea>
    </div>
    <div>
        <button>Submit</button>
    </div>
</form>