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
0
votes
1 answer

Internet Explorer, ng-pattern and input type "number" in form validation

In a web application that we are building, we came across some weird bug that only happens with Internet Explorer. The input validation as seen in this plunker works fine in all browsers except in IE (we have to support IE10+). We use type="number"…
0
votes
1 answer

Angularjs regular expression to restrict number of characters issue

I have have the regular expression $scope.pa = /^([\w-~!@#\$]+)$/i which is working fine for my requirements. Now I want to restrict this regular expression so that it can allow only 0 to 15 characters. So I have changed it to $scope.pa =…
Madasu K
  • 1,813
  • 2
  • 38
  • 72
0
votes
0 answers

How would you set the NgPattern of an Angular NgMessages Application for two given years as a date range

I have a date field like: input(name='date', type='date', ng-pattern='/^[1900-2016]$/', ng-model='dateModel') How do you set the ng-pattern for two given dates a date range. For example: only years from 1900 - 2016 are allowed? Keep in mind that we…
user4911648
0
votes
3 answers

ng-pattern for mobile number validation

I am trying to implement mobile number validation on a Visualforce page using Angular JS, but am having problems getting my head around how to write the regex expression. The requirements, as given to me, are fairly simple: The number should be 10…
Syd Mariner
  • 1
  • 1
  • 1
  • 1
0
votes
2 answers

ng-pattern allows '+' character when regex limits to digits

Am using the regex /^[0-9]+$/ to limit the input of the text box to only accept numbers. It's working fine but when the types something like +124 then also it's not setting the text box as invalid.
0
votes
2 answers

How to use ngPattern to validate an input containing restricted characters?

I try to validate the input of restricted characters. The input field only accept alphabet, dash and underscore characters. When I test the code below, the first character is accepted, but the second one raise a pattern error. My RegEx:…
Jonathan Anctil
  • 1,025
  • 3
  • 20
  • 44
0
votes
1 answer

How to use ng-pattern to limit 10 number inputs separated by commas

I want to enter in up to 10, 8 character length numbers in one text field all separated by commas. For example, 12345678,12345678,12345678,12345678..... The only thing is the numbers can only be 8 characters at max and only up to 10 numbers entered…
McMintz
  • 254
  • 6
  • 19
0
votes
1 answer

ng-pattern for range 1-72 with step 0.5 in Angular

I need pattern for input (type="text"! not number) when is available numbers from 1 to 72 and available 0.5 (1.5, 2, 2.5, 65.5 ect.) I tried by ng-pattern="'^(?:[1-9](\.[05]*)?)|(?:[1-6][0-9](\.[05]*)?)|(?:7[01](\.[05]*)?)|72$'" But not work…
Albatros
  • 51
  • 1
  • 4
0
votes
3 answers

Using ng-pattern to recognize leading zero in Angular alphanumeric field

How can I recognize a leading zero in an alphanumeric field using ng-pattern in angular?

Regex test

jenryb
  • 2,017
  • 12
  • 35
  • 72
0
votes
2 answers

AngularJs text input field regular expression

Currently, I use the following expression for my ngPattern attribute: /[^*]/ meaning that any input is allowed but it has to contain at least one char different from *. Now, additional requirement arose - the input has to be numeric only. Is there…
Ewgenij Sokolovski
  • 897
  • 1
  • 12
  • 31
0
votes
0 answers

ng-pattern not accepting '@' special character in validation

NET MVC, HTML 5 and Angularjs, i am having trouble on using ng-pattern in the password field validation. this is my pattern ng-pattern="/^(?=.*[0-9])(?=.*[!#$%^&*])[a-z0-9!#$%^&*]{8,16}$/" I need to validate the passwoerd field must contains…
user4470962
0
votes
2 answers

Regex, AngularJS validation

I'm using this pattern to restrict user to use only numbers with max 5 decimals, but it gets valid only when user inputs ' , ' as decimal point, but i want to make it that user can insert ' . ' too, code : ng-pattern="/^[0-9]+(\.[0-9]{1,5})?$/"
Mark
  • 209
  • 1
  • 5
  • 18
0
votes
2 answers

Validating character string with ng-pattern

I want an ng-pattern expression to validate a textbox in AngularJS JavaScript. Contents for this textbox must have at least one Alphabetic character, but may also contain any number of Numeric and/or Special characters. Examples: a1234$ It is…
0
votes
1 answer

Custom ng pattern expression for custom email

I want to validate an email for only certain type of kind. So I know that I need to use ng-pattern expression to make custom validation. I went through the Angular docs but I could not understand how to use it. The solution I am looking for is…
Wang'l Pakhrin
  • 858
  • 3
  • 15
  • 29
0
votes
0 answers

Uk Postcode Ng-Pattern Angularjs Not working

I have tried multiple reg ex expressions on my ng-pattern in angular js, I have test this pattern on an online regex tester and it works fine /^([Gg][Ii][Rr]…
user3355603
  • 1,091
  • 2
  • 12
  • 19