Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: input mobile number only 9 digit. #21

Closed
Chandanjee opened this issue Jun 16, 2020 · 1 comment
Closed

Issue: input mobile number only 9 digit. #21

Chandanjee opened this issue Jun 16, 2020 · 1 comment

Comments

@Chandanjee
Copy link

Chandanjee commented Jun 16, 2020

can You check in your demo mobile number input.
I am adding your pod file and validate with number.

`class func verifyPhoneNumber(text : String) -> (String, Bool) {
var verifyObj = (message : "", isVerified : false)
if text.length == 0 {
verifyObj.message = vcErrorPhoneNumber

        //        } else if text.length < 10 { //< 8 { if country code option is also on screen
        //            verifyObj.message = vcErrorValidPhoneNumber
        
    }

// else if text.length > 10{
// verifyObj.message = contactMayNOtBeGreaterThan
//
// }
else if !text.isContainsAllZeros() {
verifyObj.message = vcErrorValidPhoneNumber
print("isContainsAllZeros",verifyObj)

    } else if !text.containsNumberOnly() {
        print("text mob number:- ",text)
        verifyObj.message = vcErrorValidPhoneNumber
        print("containsNumberOnly",verifyObj)

//
} else if !text.isValidMobileNumber() && text.count < 9 {
verifyObj.message = vcErrorValidPhoneNumber
print("text mob:- ",text)
print(verifyObj)

    }
    else {
        verifyObj.isVerified = true
    }
    return verifyObj
}`

`func isContainsAllZeros() -> Bool {
let mobileNoRegEx = "^0*$";
let mobileNoTest = NSPredicate(format:"SELF MATCHES %@", mobileNoRegEx)
return mobileNoTest.evaluate(with: self)
}
func containsNumberOnly() -> Bool {
let nameRegEx = "^[0-9]+$"
let nameTest = NSPredicate(format:"SELF MATCHES %@", nameRegEx)
let test = nameTest.evaluate(with: self)
print(test)
return test
}

func isValidMobileNumber() -> Bool {
let mobileNoRegEx = "^[0-9]{8,16}$"
// let mobileNoRegEx = "^\d{3}-\d{3}-\d{4}$"
// let mobileNoRegEx = "^[0-9+]{0,1}+[0-9]{5,16}$" //
// let mobileNoRegEx = "(?:(?:\+|0{0,2})91(\s*[\- ]\s*)?|[0 ]?)?[789]\d{9}|(\d[ -]?){10}\d"

    let mobileNoTest = NSPredicate(format:"SELF MATCHES %@", mobileNoRegEx)
let texts = mobileNoTest.evaluate(with: self)
print("Number",texts)
    return texts
}`
@Chandanjee Chandanjee changed the title mobile number input only 9 digit. Issue: input mobile number only 9 digit. Jun 16, 2020
@Chandanjee
Copy link
Author

Fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant