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
1
vote
1 answer

ng-pattern (regex) to validate drive letters

I'm having little hard time with a regular expression. Any help would be greatly appreciated. Problem: I want display an error when user enters drive letters in the path. for example: if user enters C:\ or D:\ or S:\ .... the form should show an…
pmh
  • 51
  • 1
  • 7
1
vote
2 answers

looking for a regular expression to match specific decimal format in ng-pattern

i am looking for a regular expression to put in ng-pattern attribute of angular. i am looking for an expression that satisfies only a specific decimal pattern i.e. exactly one digit --> than a decimal --> exactly 2 digits i came up with…
Raas Masood
  • 1,475
  • 3
  • 23
  • 61
1
vote
2 answers

ng-pattern issue with input type number

I am facing one weird issue when trying to use ng-pattern with input type number.
Please enter an…
TheKingPinMirza
  • 7,924
  • 6
  • 51
  • 81
1
vote
1 answer

ng-pattern not working inside directive

I'm trying to wrap an in a directive so that I can handle date validation and convert it from a string to an actual Date object and maintain the Date version in the original scope. This interaction is working as expected. But the ng-pattern…
1
vote
3 answers

Smaller Work around for ng-pattern on Select

I am working on an angular app and I needed to put a pattern validation on a select element. Just using ng-pattern on select didn't work. So I created a hidden input with same model with ng-pattern on the hidden input, that didn't work either. So I…
0
votes
0 answers
0
votes
0 answers

Custom Angular Validation based on a selection radio select button

I need some help in that i have validation working partially. When one selects a payment method called CC the user input needs validation to kick in instantly and wont allow one to input the wrong number or be able to pay(the button will be…
0
votes
1 answer

AngularJS - ng-pattern on a form failing for certain special symbols such as the dollar sign

I am writing an app with AngularJS 1.5. I am trying to write a feature where the user can verify their password in the app and I am using ng-messages to try to validate the form. My from has 2 fields: password and confirm password. The 2 validation…
user1261710
  • 2,539
  • 5
  • 41
  • 72
0
votes
1 answer

Angular js allow alphabetical caharacters and special characters but not numbers

My directive is below. What i want is that to allow alphabetical caharacters and special characters but not numbers. How can we changed that based on my code below.Thank you. app.directive('validEn', function () { return { …
user9551058
0
votes
0 answers

Ng-Pattern performance issue with multiline regex

I have performance problems with ng-pattern on a textarea input. I have a Regex expression to simply check if the code contains script, image or iframe tag. If I paste a script with multiple lines, after a certain size the entire input and page…
0
votes
0 answers

ngPattern problem with dynamic forms inside ngRepeat

I've been stuck on a problem for a while now and I feel I've exhausted all efforts. I have a dynamic form created using an ng-repeat, for some reason ng-pattern will not work in this scenario, ng-required works perfect though. field.label = "test…
0
votes
1 answer

Angular js Ng-pattern does not allow update the model

i have to validate the text box which shows the error message when user enters 4 digit as 9999.so i have used the ng-pattern method to show error message but ng-pattern does n't allow to update the object.my code is given below: …
Sathish
  • 149
  • 2
  • 19
0
votes
1 answer

How to debug ng-pattern

I'm working on custom form validation for an Angular application using ng-pattern. In my form I have:
Sara Fuerst
  • 5,688
  • 8
  • 43
  • 86
0
votes
3 answers

How to allow only 3 digit and one dot in Regular Expression

I want to do like this : 3.40 and not more than 3 characters and one dot:
0
votes
3 answers

How to edit input style by using ng-pattern

I made a small js here I also add the code to the Stack overflow snippet but for some reason it doesn't work to me var myApp = angular.module('myApp',[]); function MyCtrl($scope) { $scope.my_model = '' $scope.my_regex =…
Robdll
  • 5,865
  • 7
  • 31
  • 51