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

Indian Mobile Number starts from 98,99,97,77
Uk Mobile Number Starts from 0756,0758,0757,0758

if indian number found then show Indian Number Else Uk Number.

I have a code as Follows:
C#
var obj = ['9869472915', '9930229815', '022-22551515', '07965869845', '07966859863'];
            var checkNumber = obj;
            if ($.each(checkNumber, function (i, val) { debugger; val.indexOf(9) == 0 })) {
                alert('Indian Mobile Number Found.');
            }
            else {
                alert('Uk mobile Number Found');
            }


Its Not Works for Me.
Thanks in Advance
harshal
Posted
Comments
[no name] 31-Jul-14 10:59am    
Team help Please.

1 solution

Jquery is a dom manipulation tool.

It's not required for what you're trying to do.

Try this:

JavaScript
var obj = ['9869472915', '9930229815', '022-22551515', '07965869845', '07966859863'];
var checkNumber = obj;
var indian = false;
for(var i in obj) {
  var num = obj[i];
  if(num.indexOf(9) == 0)
  {
    indian = true;
  }
  if(indian) break;
}
if(indian) {
    alert('Indian Mobile Number Found.');
}
else {
    alert('Uk mobile Number Found');
}


Jquery uses CSS selector syntax.

http://www.w3schools.com/cssref/css_selectors.asp[^]

What Jquery expects is an array of CSS selectors, not an array of values. Jquery will try and select DOM elements using the selectors you've provided. Which in your case will most likely result in no matches.
 
Share this answer
 
v2
Comments
[no name] 1-Aug-14 1:09am    
My Vote of 5

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