javascript - AngularJS get invalid elements group without form -


is there nice way group of elements without using form? problem work .net mvc , html.beginform removes form inside itself.

<fieldset name="user_fieldset">    <input type="text" ng-model="firstname" />    <input type="text" ng-model="lastname" />    ... </fieldset> <button ng-disabled="user_fieldset.$valid" ng-class="{'disabled' : user_fieldset.$valid}">next</button> 

you can use ng-form directive attribute.

the example angularjs hub:

angular.module("mainmodule", [])    .controller("maincontroller", function ($scope)    {      $scope.person = {};    });
<!doctype html>  <html>  <head>      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>    <style>      label      {        display: inline-block;        width: 120px;        vertical-align: middle;      }        input      {        display: inline-block;        vertical-align: middle;      }        input.ng-invalid      {        border: solid red 2px;      }        form      {        padding: 10px;      }        textarea      {        width: 250px;        height: 160px;      }    </style>  </head>    <body ng-app="mainmodule">    <div ng-controller="maincontroller">      <form name="personform" novalidate>        <label for="firstnameedit">first name:</label>        <input id="firstnameedit" type="text" name="firstname" ng-model="person.firstname" required /><br />        <label for="lastnameedit">last name:</label>        <input id="lastnameedit" type="text" name="lastname" ng-model="person.lastname" required /><br />        <ng-form name="addressform">          <label for="addressedit">address:</label>          <input id="addressedit" type="text" name="address" ng-model="person.address" /><br />          <label for="zipedit">zip code:</label>          <input id="zipedit" type="number" name="zip" ng-model="person.zip" required /><br />          <label for="cityedit">city:</label>          <input id="cityedit" type="text" name="city" ng-model="person.city" /><br />          <label for="stateprovinceedit">state/province:</label>          <input id="stateprovinceedit" type="text" name="stateprovince" ng-model="person.stateprovince" /><br />          <label for="countryedit">country:</label>          <input id="countryedit" type="text" name="country" ng-model="person.country" />        </ng-form>      </form>      <br />      <strong><label for="userdebugtext">person:</label></strong><br />      <textarea id="userdebugtext">{{person | json}}</textarea><br />      <br />      <strong>form validity:</strong><br />      <ul>        <li><strong>personform.$valid =</strong> {{personform.$valid}}</li>        <li><strong>personform.addressform.$valid =</strong> {{personform.addressform.$valid}}</li>        <li><strong>personform.firstname.$valid =</strong> {{personform.firstname.$valid}}</li>        <li><strong>personform.lastname.$valid =</strong> {{personform.lastname.$valid}}</li>        <li><strong>personform.addressform.zip.$valid =</strong> {{personform.addressform.zip.$valid}}</li>      </ul>    </div>  </body>  </html>


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -