form-validation

Built with Grunt Build Status Dependency Status codecov.io ReviewNinja

Angular ui form validation

Perform your form validation using re-usable directives and API to create your own validation types.

Installation

Bower

    bower install form-validation
    <script src="bower_components/form-validation/dist/scripts/vendor.js"></script>
    <script src="bower_components/form-validation/dist/scripts/scripts.js"></script>

CDN

You can use rawgit.com's cdn url to access the files in the Bower repository. These files are hosted by MaxCDN. Just alter the version as you need.
CODE
angular.module('myApp',['ui.formValidation']);

Directives :

<form name="test">
   <input type="text" ng-model="uname" name="uname" required>
   <div ui-form-validation-message field="uname" validation="required">
      Please enter a valid name
   </div>
 </form>

Use comma separated value for multiple validation on a field

<form name="test">
   <input type="email"  ng-model="email" name="email" required>
   <div ui-form-validation-message field="email" validation="required,email">
      Please enter a valid email
   </div>
</form>
<form name="test">
   <input ng-model="userName" name="userName" reg-exp="^[A-z]+$" validation="customAlphabet" ui-custom-validation/>
   <div ui-form-validation-message field="userName" validation="customAlphabet">
      Please enter a valid user name
    </div>
</form>
<form name="test">
     <input ng-model="quantity" name="quantity"  ui-number/>
     <div ui-form-validation-message field="quantity" validation="uiNumber">
        Please enter a valid quantity
     </div>
 </form>
<form name="test">
      <input ng-model="value1" name="pwd"/>
      <input ng-model="value2" name="cnfPwd" ui-same-as="pwd"/>
      <div ui-form-validation-message field="value2" validation="uiSameAs">
        Password does not match the confirmation password.
      </div>
</form>