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
0
votes
2 answers

AngularJS with ng-pattern in form does not send invalid field to server

I want to validate a text input in form, so the submit of the form could not be done until the input match a regular expression. But when I type a wrong field value and I clik submit the form is submitted but the input value is not sent to the…
MABC
  • 576
  • 2
  • 11
  • 29
0
votes
1 answer

How to validate value 1 and 1.00 as same and 1.01 as different in angular

How to treat 1 and the number of decimals should be zero eg) 1.000 as same show the alert pop up number should be same.And the maximum number length of the texbox is 7. eg)1 and 1.00000001 be different And the number be 1 and 1.01 as…
0
votes
1 answer

Regex digits with length and some specific characters

I have a phone number input field where it must: Allows spaces and "-" and "+" characters. Have 12 characters max including the special characters (ex +12345678910). I tried but my best result was ng-pattern="/^\+?\d{0,11}?$/". How to make this…
Anna
  • 839
  • 2
  • 17
  • 33
0
votes
2 answers

regex for multiple IPs comma separated with or without subnet

I have regex for IPv4 address: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ and i have regex for IPv4 CIDR range…
0
votes
1 answer

Restricting few special characters like %,& and " in input field by ng-pattern

I have a password where It should be minimum 8 character with alpha numeric and symbol except &,",% .I given ng-pattern and restricted few symbols. but when I type & too it is accepting. This ng-Pattern normally works. when you enter & and $ it is…
Nicoleta Wilskon
  • 687
  • 1
  • 10
  • 32
0
votes
2 answers

Regex acts weird

I want to create a regex expression that I can pass to ng-pattern so that the input can only be valid if the string has only uppercase/lowercase latin letters from a to z, n with tilde, and vowels with acute accents; as well as dot. I came up with…
Edd
  • 1,948
  • 4
  • 21
  • 29
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
0 answers

Adding ng-pattern dyanmically through a directive isn't kicking off validation

I'm attempting to add ng-pattern to specific inputs on specific forms using the following directive. It's adding the ng-pattern, but the validation isn't working. However, the validation works fine whenever I add the ng-pattern manually to the…
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
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
1 answer

Text input validation using ng-pattern in AngularJS

I want to validate a text input with ng-pattern directory in AngularJs. The text input can have multiple IP addresses and IP ranges with , (comma) separated. for an example; 172.168.21.3, 172.168.45.3/8, 172.53.23.12 Can someone help me on this.
0
votes
1 answer

Is ng-pattern possible on contenteditable elements?

Can't seem to find any info on this. Is it possible to use ng-pattern on a contenteditable div? When I try it doesn't work:
{{ x.number }}
More specifically, the ng…
0
votes
1 answer

ngPattern is not working after upgrading Angular JS 1.2.x to 1.4.x

The pattern validation using angular ngPattern is not working after upgrading the Angular JS library to 1.4.1. See the code below.
field1Value =…
Saidh
  • 1,131
  • 1
  • 12
  • 21
-1
votes
2 answers

Regular Expression for ng-pattern

I want my input text to accept following characters only 1,2,3,4 and 5+ And to validate the above character I need a regular expression (ng-pattern). Is their any perfect website to learn Regular expression?
Himanshu Shekhar
  • 1,196
  • 1
  • 16
  • 35