Questions tagged [angularjs-ng-pattern]

An optional directive that can be used to check values for input: Input control follows HTML5 input types and polyfills the HTML5 validation behavior for older browsers.

Sets pattern validation error key if the ngModel value does not match a RegExp found by evaluating the Angular expression given in the attribute value. If the expression evaluates to a RegExp object, then this is used directly. If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it in ^ and $ characters. For instance, "abc" will be converted to new RegExp('^abc$').

Note: Avoid using the g flag on the RegExp, as it will cause each successive search to start at the index of the last search's match, thus not taking the whole input value into account.

50 questions
12
votes
4 answers

How to add password validation using regular expression in angularjs according to certain criterion?

I want to validate password entered by user for following criteria : Password should be at least 8 characters long and should contain one number,one character and one special character. For it I used following regular expression…
5
votes
2 answers

ng-pattern should not match supplied pattern

In ng-pattern we have the option of specifying that the field should match a specific pattern. How can we specify that it should NOT match the specified pattern? Example, [\]{}`()';@&$]/" /> Here, I DONT want…
Tarun Dugar
  • 8,921
  • 8
  • 42
  • 79
5
votes
3 answers

ng-pattern with regex having double quotes does not escape correctly

I have a ng-pattern validation for a regex of ^[^\./:*\?\"<>\|]{1}[^\/:*\?\"<>\|]{0,254}$ which basically tests the invalid chars in filepath and teh limit. but when i have the ng-pattern specified as ng-pattern =…
looneytunes
  • 741
  • 4
  • 16
  • 35
4
votes
2 answers

Angularjs regular expression

In my Angularjs application I need to have regular expression for two patterns for form validation with the following condition. Pattern 1 : The input box should accept alphanumeric with no space and it should also allow the user to use the…
Madasu K
  • 1,813
  • 2
  • 38
  • 72
4
votes
2 answers

Australian Mobile number regular expression validation needs to allow space in between number

I need to validate the mobile number first text input starting with 04 should be total 10 digits including 04(eg : 0412345678) my input field is below
sheravanan
  • 91
  • 1
  • 6
3
votes
2 answers

Regular expression : match either of two conditions?

Hi I don't know much about regular expression. But I need it in form validation using angularJs. Below is the requirement The input box should accept only if either (1) first 2 letters alpha + 6 numeric or (2) 8 numeric Below are some correct…
shreyansh
  • 1,637
  • 4
  • 26
  • 46
3
votes
2 answers

Require two words in textbox, with AngularJS

I really struggling with this. I need to force the user to write the first and last name, in only one textbox. I using AngularJS, and I want to validate text field using ng-pattern. The field should accept all characters, and require 2 words. This…
2
votes
1 answer

ng-pattern for only hebrew characters

I want to use ng-pattern validate my text input field that should accept only Hebrew characters, sometimes the input are ok and sometimes they are being rejected for some reason. (the first one is validate the second letter is not and…
2
votes
1 answer

ng-pattern regex Error: [$parse:lexerr] Lexer Error

I have this as my regex pattern (^([Aa][Ss])[0-9]{8})|(^6[0-9]{7}) i get console errors below, but it works!: libraries-c8d65edf41.js:22505 Error: [$parse:lexerr] Lexer Error: Unexpected next character at columns 1-1 [^] in expression…
2
votes
3 answers

regex for ng-pattern for filepath

I have arrived at a regex for file path that has these conditions, Must match regex ^(\\\\[^\\]+\\[^\\]+|https?://[^/]+), so either something like \server\share (optionally followed by one or more "\folder"s), or an HTTP(S) URL Cannot contain any…
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
1 answer

spicy angularjs regex

I've been working on a regex problem for angularJs ng-pattern which needs: Cannot be blanks A minimum of 1 character and a maximum of 32 characters Spaces ONLY are not allowed Acceptable special characters(!@#$%&*-+=[]:;',.? ) The answer is not…
user1070111
  • 59
  • 2
  • 7
1
vote
2 answers

ng-pattern to check amount should be of 1 to 3 digit with 2 decimal value (999.99)?

I am working on a transaction form. In the form, there is a field name Amount. I am using this ng-pattern i.e. ng-pattern="/^[1-9][0-9]{0,2}(?:,?[0-9]{3}){0,3}(?:\.[0-9]{1,2})?$/" which allow only number with 2 decimal value. Also, 0 is also not…
Nishant
  • 127
  • 12
1
vote
1 answer

angularjs ng-pattern change css style of elements based on regex condition

In my angularjs form, I am checking the password pattern with a regex that checks for multiple conditions. Based on different condition checks of this regex, I want to change the css for one of the elements. Jsfiddle link Here . The source model…
Bonnard
  • 389
  • 2
  • 8
  • 26
1
2 3 4