Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng-valid

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-valid

An AngularJS directive to trigger a method when an input is valid (or invalid).

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
Maintainers
1
Weekly downloads
 
Created
Source

ngValid

An AngularJS directive to trigger a method when an input is valid (or invalid).

The problem

This inside a controller:

if (form.inputName.$valid) {
    doSomething()
}

and also this:

$scope.$watch('inputName', function(value) {
    if (isValid(value)) {
        doSomething()
    }
});

The solution

<input type="text" ng-model="inputName" ng-valid="doSomething()" required>

How to install it

  • Bower:
bower install --save ng-valid
  • HTML:
<script src="bower_components/angular.js"></script>
<script src="bower_components/ng-valid/dist/ng-valid.min.js"></script>
  • AngularJS:
var app = angular.module('app', ['ngValid']);

How to use it

Just add the ng-valid attribute and a method to be called when the input is valid:

<input type="text" ng-model="inputName" ng-valid="doSomething()" required>

You can also add the optional attribute ng-invalid to invoke a method when the input is not valid:

<input type="text" ng-model="inputName" ng-valid="doSomething()" ng-invalid="doSomethingElse()" required>

License

See the LICENSE file.

Keywords

FAQs

Package last updated on 10 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc