Skip to content

Restricts the characters that may be entered into a Input Field

Notifications You must be signed in to change notification settings

AhmadShahid/angular-nghalt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Angular Halt

A simple, pure AngularJS directive to restricts the characters that may be entered into a text field.

Usage

Install using Bower:

# install package and add it to bower.json dependencies
$ bower install angular-nghalt --save

Include the script and style:

<script src="bower_modules/angular-nghalt/src/ng-hide.js"></script>

Include the ngHalt dependency on your Angular module:

angular.module('demoApp', ['ngHalt']);

Usage

For alpha

<input type="text" ng-halt="alpha: true">

For alphanumeric

<input type="text" ng-halt="alpha: true,numeric:true">

For alphanumeric + special characters

<input type="text" ng-halt="alpha: true,numeric:true ,special:true">

AllowSpace

<input type="text" ng-halt="alpha: true,numeric:true ,special:true,allowSpace:true">

To pass custom regex

<input type="text" ng-halt="regex:^[A-Za-z]*$">

Options

Pass a string to ng-halt like this: ng-halt="alpha: true, special: false"

Available tests

Option Default Description
alpha true Can accept alphabet(A-Za-z).
numeric true Can accept Number(0-9).
special true Can accept non-word character
maxlength false Check maximum length. Defaults to 50.
allowSpace true Can accept space.
regex false Pass a custom regex to restrict user from input.

About

Restricts the characters that may be entered into a Input Field

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published