Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team,

My Condiion are Not Working Please Let me Know .
Kindly Help

C#
var obj = ['+919820530598', '+918869472915', '+912222551515', '+912212315', '+912265561115', '+4471628111', '+4471613222', '4471245678'];
            var checkNumber = obj;
            $.each(checkNumber, function (i, val) {
                debugger;
                if (val.indexOf(9) == 1) {
                    debugger;
                    if (val.indexOf(1) == 11 && val.indexOf(5) == 12) {
                        debugger;
                        alert(val + ' is a Indian Mobile Number ');
                    }
                    else {
                        alert(' Mobile Number ' + val + ' Not in the List of UK and India ');
                    }
                }
                else if (val.indexOf(+44) == 1) {
                    debugger;
                    if (val.indexOf(6) == 3 && val.indexOf(8) == 5) {
                        debugger;
                        alert(val + ' is a UK Mobile Number ');
                    }
                    else {
                        alert(' Mobile Number ' + val + ' Not in the List of UK and India ');
                    }
                }

            })



Thanks in Advance
harshal
Posted
Comments
Thanks7872 1-Aug-14 5:18am    
This is third time you have posted similar question and i don't remember how many of your posts got deleted due to reposts. Its not allowed here and will be considered abuse if you don't stop it.
R Harshal 1-Aug-14 5:22am    
Hi Rohan,
If you See Properly, this time Conditions are Different.I have not repeated the question.
R Harshal 1-Aug-14 5:29am    
Mr.Rohan why r u not trying to understand the Problem ..
Accorcing to Code Project terms and Conditions ,I did not say to give me Answer for my Question .I already stuck in my Condition that why i am trying to get help from Code Team .
R Harshal 1-Aug-14 5:32am    
In This Condition ,'+918869472915' is a Indian Number but it returns me False .This is my Problem .If you Check i have not submitted this type of question before this ..so how could you say this is a repeated question ..Please check it.
R Harshal 1-Aug-14 5:51am    
Please Kindly Revert .

1 solution

The problem i see here is that you are looking for the result but ignoring the data. You didin't even looked at the return of the indexOf test.
First:
Quote:
In This Condition ,'+918869472915' is a Indian Number but it returns me False .This is my Problem .If you Check i have not submitted this type of question before this ..so how could you say this is a repeated question ..Please check it.

That's incorrect. Because this:
Quote:
if (val.indexOf(1) == 11 && val.indexOf(5) == 12) {

Will find something like this:

+9(1)886947291(5)
---2-------------12

You could use val.charAt(11) to check if the character equals to the desired value at a specific position. If the Indian numbers always have the number 15 at the end, you should just check for it.

Anyway, people are less eager to help if you just ask for solutions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900