Hitu Bansal
Hitu Bansal

Reputation: 3137

Why is a red border shown by default in a form?

I have following HTML:

  <form ng-submit="submitForm()"  method="POST">
    <div class="formRow"><input type="email" placeholder="Email" ng-model="form.emailId"  name="email" required></div>
    <button type="submit" ngclick="Submit">Signin</button>

It is showing a red border by default. Why?

When I inspect the HTML in Firefox I see this:

<input type="email" required="" name="email" ng-model="form.emailId" placeholder="Email" class="ng-pristine ng-invalid ng-invalid-required ng-valid-email">

Any idea?

Upvotes: 0

Views: 921

Answers (1)

devdRew
devdRew

Reputation: 4581

That could be that this is browser highlighting. In HTML5 we have form input validation, and your input has type email. That is why if the content does not match email field requirements there could appear red border.

To prevent this set novalidate attribute to the form.

<form novalidate action="/some/action" method="POST"></form>

Hope that helps somehow.

novalidate on W3C.

Upvotes: 1

Related Questions