angular.validator.regexp

Work In Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

Use regexp validator to restrict the input to any Regular Expression.

Usage

In HTML Template Binding

<input type="text" ng:validate="regexp:expression"/>

In JavaScript

angular.validator.regexp(value, expression);

Parameters

CSS

ng-validation-error

Example

<script> var ssn = /^\d\d\d-\d\d-\d\d\d\d$/; </script> Enter valid SSN: <input name="ssn" value="123-45-6789" ng:validate="regexp:$window.ssn" > it('should invalidate non ssn', function(){ var textBox = element('.doc-example :input'); expect(textBox.attr('className')).not().toMatch(/ng-validation-error/); expect(textBox.val()).toEqual('123-45-6789'); input('ssn').enter('123-45-67890'); expect(textBox.attr('className')).toMatch(/ng-validation-error/); });