jothi jothi - 1 year ago 54
AngularJS Question

two forms with same name angular js validation

can we have two forms with the same form name on the same page ?

will angular validation work properly for each form ?

For example

<form name="ajax">
<input type="text" name="fname" />
</form>
<form name="ajax">
<input type="text" name="fname" />
</form>

Answer Source

As per my understanding angular validation is not working properly with same form name in same page.

Angular will only consider the last form name

Ex:

<form name="myForm">
<input name="myInput" ng-model="myInput" required>
</form>

<form name="myForm">
<input type="email" name="myInpu" ng-model="myInpu">
</form>



<p>The input's valid state is:</p>
<h1>Form 1 : {{myForm.myInput.$valid}}</h1>
<h1>Form 2 : {{myForm.myInpu.$valid}}</h1>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download