Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
mobile number for Russia Federation#2207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for your contribution! I'll triage and take a look at it as soon as possible! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for your contribution.
Overall, it looks good. Only 2 changes are needed + a test case to be added and we are good to go.
For the test case, you can inspire frommobileUK
test:
jquery-validation/test/methods.js
Lines 850 to 869 in3a7e593
QUnit.test("mobileUK",function(assert){ | |
varmethod=methodTest("mobileUK"); | |
assert.ok(method("07134234323"),"Valid UK Mobile Number"); | |
assert.ok(method("07334234323"),"Valid UK Mobile Number"); | |
assert.ok(method("07624234323"),"Valid UK Mobile Number"); | |
assert.ok(method("07734234323"),"Valid UK Mobile Number"); | |
assert.ok(method("+447134234323"),"Valid UK Mobile Number"); | |
assert.ok(method("+447334234323"),"Valid UK Mobile Number"); | |
assert.ok(method("+447624234323"),"Valid UK Mobile Number"); | |
assert.ok(method("+447734234323"),"Valid UK Mobile Number"); | |
assert.ok(!method("07034234323"),"Invalid UK Mobile Number"); | |
assert.ok(!method("0753423432"),"Invalid UK Mobile Number"); | |
assert.ok(!method("07604234323"),"Invalid UK Mobile Number"); | |
assert.ok(!method("077342343234"),"Invalid UK Mobile Number"); | |
assert.ok(!method("044342343234"),"Invalid UK Mobile Number"); | |
assert.ok(!method("+44753423432"),"Invalid UK Mobile Number"); | |
assert.ok(!method("+447604234323"),"Invalid UK Mobile Number"); | |
assert.ok(!method("+4477342343234"),"Invalid UK Mobile Number"); | |
assert.ok(!method("+4444342343234"),"Invalid UK Mobile Number"); | |
}); |
You can add your tests to the same file.
Thanks!
src/additional/mobileRU.js Outdated
@@ -0,0 +1,6 @@ | |||
/* mobile number for Russia Fedaration */ | |||
$.validator.addMethod( "mobileRU", function( phone_number, element ) { | |||
phone_number = phone_number.replace( /\(|\)|\s+|-/g, "" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please create a new variablephoneNumber
or something else and assign the result to it.
src/additional/mobileRU.js Outdated
$.validator.addMethod( "mobileRU", function( phone_number, element ) { | ||
phone_number = phone_number.replace( /\(|\)|\s+|-/g, "" ); | ||
return this.optional( element ) || phone_number.length > 9 && | ||
phone_number.match( /^((\+7|7|8)+([0-9]){10})$/ ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please useregex.test
instead ofstring.match
. We only need to know whether the string matches the regex or not.phone_number.match( /^((\+7|7|8)+([0-9]){10})$/ )
=>/^((\+7|7|8)+([0-9]){10})$/.test( phone_number )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM 👍
Thanks a lot for working on this :)
Description
Thank you!