Giter Site home page Giter Site logo

flaxhaxx / angular-input-types Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 179 KB

Input types with autocomplete and validation for AngularJS

Home Page: https://www.blitter.se/angular-input-types/examples/

License: MIT License

JavaScript 100.00%
personnummer angular swedish-ssn personnummervalidering validation validering organisaionsnummer angularjs directive form-validation

angular-input-types's Introduction

Angular Input Types

npm version Build Status Dependency Status peerDependency Status devDependency Status

Angular Input Types is used to create form inputs which help users enter the correct format using autocomplete and validation. See available input types below.

Demo

There is a demo at https://www.blitter.se/angular-input-types/examples/

Installation

Several options are available:

Usage

Include angular-input-types.min.js on the page.

<script src="angular-input-types.min.js"></script>

Include the inputTypes dependency in on your AngularJS module.

var app = angular.module('exampleApp', [ 'inputTypes' ]);

See how to use different input types below.

Swedish SSN (i.e. personnummer)

Helps the user to enter a swedish SSN in the format of yyyymmdd-nnnn.

The input must have an ng-model for the validation to work.

<input type="tel" id="personnummer" ng-model="personnummer" input-personnummer/>

Swedish organization number

Helps the user to enter an swedish organization number in the format of nnnnnn-nnnn or nnnnnnnn-nnnn. Also allows Swedish SSN as that could be an organization number.

The input must have an ng-model for the validation to work.

<input type="tel" id="orgnr" ng-model="orgnr" input-orgnr/>

Number

Helps the user to enter a number by adding thousand separators and restricting number of decimals.

The input must have an ng-model for the validation to work. The type has to be tel to work in Firefox on Android.

<input type="tel" id="number" ng-model="number" input-number/>

The thousand separator and decimal separators comes from $locale. You can override these like this.

angular.module('myApp').run(['$locale', function($locale) {
  $locale.NUMBER_FORMATS.GROUP_SEP = ' '; // Use space as thousand separator
  $locale.NUMBER_FORMATS.DECIMAL_SEP = ','; // Use comma as decimal separator
}])

Change number of decimals for all input-number fields. Default is no decimals.

angular.module('myApp').config(['inputNumberProvider', function(inputNumberProvider) {
    inputNumberProvider.nrOfDecimals = 2;
}]);

Change number of decimals for a single field.

<input type="tel" id="number" ng-model="number" input-number decimals="2"/>

Set a minimum allowed value.

<!-- This example only allows positive values -->
<input type="tel" id="number" ng-model="number" input-number min="0"/>

Time

Helps the user to enter a time using native time input on mobile devices by setting type="time" on the input element. The input-time attribute adds validation plus autocomplete as fallback.

The input must have an ng-model for the validation to work.

<input type="time" id="time" ng-model="time" input-time/>

input-time on Android

angular-input-types's People

Contributors

flaxhaxx avatar

Watchers

 avatar

Forkers

phoenisis

angular-input-types's Issues

ng-strict-di fails

When I load the minified version and decorate my app with ng-strict-di. E.g. <html ng-app="root" ng-strict-di lang="sv-se">. The library fails to load. Removing the decoration and it works.

Error: $injector:strictdi
Explicit annotation required

function($browser,validate is not using explicit annotation and cannot be invoked in strict mode

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.