Angular.js: ngPattern does not handle trailing whitespace

Created on 15 Oct 2014  路  3Comments  路  Source: angular/angular.js

When using a pattern that does not allow trailing whitespace (ng-pattern="/^[a-zA-Z0-9]*$/" for example), entering in the trailing whitespace WILL NOT trigger the ngPattern invalid.

Please see http://plnkr.co/edit/xeWv4bpUiJnYeGlcD0vE?p=preview for test case.

This is against AngularJS 1.3.0 but I suspect the 1.2 branch also has this bug.

Most helpful comment

You have to add ng-trim="false" not to trim whitespaces. Please read the documentation

All 3 comments

You have to add ng-trim="false" not to trim whitespaces. Please read the documentation

Doh, thanks for the help!

Why oh why did the authors thought ng-trim="true" is a good default ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jpsimons picture jpsimons  路  3Comments

jtorbicki picture jtorbicki  路  3Comments

ceymard picture ceymard  路  3Comments

brijesh1ec picture brijesh1ec  路  3Comments

th0r picture th0r  路  3Comments