Questions tagged [ng-pattern]

HTML input element control with angular data-binding. Input control follows HTML5 input types and polyfills the HTML5 validation behavior for older browsers.

HTML input element control with angular data-binding. Input control follows HTML5 input types and polyfills the HTML5 validation behavior for older browsers.

Source: http://docs.angularjs.org/api/ng/directive/input

170 questions
2
votes
1 answer

Angular dynamic ngPattern

I'm trying to implement dynamic ngPattern. My regex changes when the user clicks on a button or selects a value from dropdown. But for some reason this doesnt seem to work. Below is the code. app.controller('testController',function(){ …
2
votes
1 answer

ng pattern for allowing only '-' in input text box

Is there any pattern that will allow only '-' in the input text box and deny entering other special characters like @, #, $ etc.I tried with the pattern ng-pattern="/^[a-zA-Z0-9]*$/" which will deny all special characters from being entered in the…
forgottofly
  • 2,729
  • 11
  • 51
  • 93
2
votes
1 answer

AngularJS ng-pattern regEx not working while using the templateCache

I have the below text field where I'm using the ng-pattern for validation and displaying the message using ng-message. The validation works fine with the both the regex (/^\d+$/ or /^[0-9]+$/), but for some reason the regex (/^\d+$/) is returning…
Karthilxg
  • 21
  • 4
2
votes
1 answer

dynamically creating a regex for ng-pattern for only numbers within a range

I have an input form field, of type number, that I am attempting to let Angular validate (which seems excellent so far), however I cannot seem to get the correct syntax for dynamically creating a regex to apply to ng-pattern that restricts the user…
Kramericus
  • 47
  • 1
  • 7
2
votes
1 answer

How to give regex pattern in scope of angular js

I have an input field which looks like It works fine and shows validation as expected. I just wanted…
sms
  • 426
  • 1
  • 8
  • 23
2
votes
1 answer

Show ? in textbox when textbox have ng-pattern for numeric validation

I need to show '?' when the value not able to read from scanner which returns me value by including '?' Let say document has sr no as '123' but let say for some reason scanner not able to read it then it returns me as "12?" or "???" or "?23" or…
user3249448
  • 1,369
  • 2
  • 14
  • 34
2
votes
1 answer

How to re-validate immediately when changing regex used by ngPattern

Say I have a textbox validated by ngPattern that is currently valid. I now change the regex to one that does not match the textbox's value. Angular does not immediately pick up that the textbox is now invalid - the user must make a change (eg.…
Mike Chamberlain
  • 39,692
  • 27
  • 110
  • 158
2
votes
1 answer

Angular ng-pattern preventing value from binding

I have an input that uses ng-pattern like so: However, if I try and change my payment.amount in scope, like so: $scope.payment.amount = 150.5; It fails to…
1
vote
1 answer

regex look-behind expression incompatibily with IE

I am using this regex expression for an input. When I try it in Chrome, it works well, but not when I try in IE. The regex editor that I am using advice me that the negative look-behind expression could not work for some browsers. How can I adapt…
jsdj21
  • 13
  • 2
1
vote
1 answer

ng-pattern for PCRE

I have this pattern for an input text field: /[\p{L}\'.\- ]{3,30}/ My intention is to accept the most broadly names of people on several alphabets of the world (Latin, Cyrillic, Chinese, etc.) It was tested in Regex101 and it works great. On other…
limakid
  • 71
  • 11
1
vote
0 answers

ng-pattern does not work when pattern set dynamically in ng-repeat

I have some sets of patterns in my controller. I am trying to set this pattern dynamically for ng-pattern using ng-repeat. Pattern example : $scope.codePattern = (function () { var regexp = /^([a-zA-Z0-9_]+){2,}$/; return { test(value) { …
1
vote
0 answers

How to allow only three numbers before a decimal point and two numbers after it. Is there a regex for this?

Only numbers between 0.00 and 100.00 can be allowed. The number can also be without decimal point. I am trying to use this regex, /^[1-9][0-9]{0,2}(?:,?[0-9]{3}){0,3}(?:\.[0-9]{1,2})?$/ But this allows more than 3 numbers before decimal…
1
vote
1 answer

Valid regex expressions won't work with AngularJS

I'd like to check if user input is correct for phone numbers in two formats: 01 1234567 (two numbers, a space, seven numbers) +12 123 123 123 123 (plus sign, two numbers, a space, three numbers, a space, three numbers, a space, three numbers no…
menteith
  • 596
  • 14
  • 51
1
vote
1 answer

Html pattern text input validation ng-pattern="/^-?[0-99]+(.[0-99]{0,2})?$/"

if text box value preceed with .(dot) it should append 0(Zero) for example: .50 => result should be 0.50 also if it is 5. it should be 5.0
sridhar
  • 321
  • 1
  • 3
  • 18
1
vote
1 answer

How do i use Regular expression in ng-pattern to avoid certain special character?

I have to avoid some some special characters in ng-pattern. I can able to avoid all special characters by using following code ng-pattern="/^[a-zA-Z0-9]*$/" But I have to avoid only these charecters %;:'",<> How to do write ng-pattern Update:…
Vishnu
  • 745
  • 12
  • 32
1 2
3
11 12