10 examples of 'mobile number validation in angularjs' in JavaScript

Every line of 'mobile number validation in angularjs' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
69function validateNumber(numberString: string, validations: Validations) {
70 if (numberString === '') {
71 return;
72 }
73
74 const match = numberString.match(numberPattern);
75
76 if (match === null) {
77 return validations.add(validationType.INVALID_FORMAT);
78 }
79
80 const [, first, second] = match;
81
82 if (first.length !== second.length) {
83 return validations.add(validationType.INVALID_FORMAT);
84 }
85
86 if (Number.parseInt(first, 10) > Number.parseInt(second, 10)) {
87 return validations.add(validationType.INVALID_FORMAT);
88 }
89
90 return validations.add(validationType.VALID_NUMBER);
91}
32function positiveNumberValidator(control: FormControl): any {
33 if (!control.value) return null;
34 const price = parseInt(control.value);
35 return price === null || typeof price === 'number' && price > 0
36 ? null : {positivenumber: true};
37}
7function checkMobile(phone_val){
8 var pattern=/(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
9 return pattern.test(phone_val);
10}
23self.isValidNumber = function isValidNumber(value) {
24 return !isEmpty(value) ? TelephonyMediator.IsValidNumber(value) : true;
25};
37static mobile(control) {
38 if (isEmptyInputValue(control.value)) {
39 return null;
40 }
41
42 return !regs.mobile.test(control.value) ? {mobile:true} : null;
43
44 }
60function positiveIntegerValidator($elt) {
61 let value = $elt.val().trim().replace(/^0+(.+)/, '$1');
62 $elt.val(value);
63 if (!value) {
64 return;
65 }
66 if (/^[0-9]+$/.test(value)) {
67 // Check that we are in the positive range of a golang int64 max value, which is
68 // 9223372036854775807 minus a safety marge due to comparison rounding errors.
69 if (parseInt(value) > 9000000000000000000) {
70 return {msg: "Value out of bound."};
71 }
72 } else {
73 return {msg: "Value must be a positive integer."};
74 }
75}
8function validateNumber(num) {
9 num = (num + '').replace(/\s+|-/g, '');
10
11 if (!/^\d+$/.test(num)) {
12 return false;
13 }
14
15 var card = cardFromNumber(num);
16
17 if (card) {
18 var cardNumbers = A(card.length);
19
20 return ( cardNumbers.includes(num.length)) && (card.luhn === false || luhnCheck(num));
21 }
22
23 return false;
24}
52mobile() {
53 return !/^1[345789]\d{9}$/.test(this.value) && `请输入11位的手机号码`;
54}
29positiveNumberValidator(control:FormControl):any{
30 if(!control.value){
31 return null;
32 }
33 let price = parseInt(control.value);
34
35 if(price>0){
36 return null;
37 }else{
38 return {positiveNumber:true};
39 }
40}
40function isValidPhone(value) {
41 return /^[0-9]+$/ig.test(value)
42}

Related snippets