javascript - Comparing numbers wrong -


i have following js compares credit card number length:

validate: function () {     var cclength = $('.credit-card input[name="cc_number"]').val().length;     var cardtype = parseint($('.credit-card .credit-card-type .selected').attr('rel'));     if (!isnan(cardtype)) {         console.log(cclength); //11         console.log(provider[cardtype].validlength.split(',')); // ["16", "13"]          if (cclength == 0 || (cardtype > 0 && (cclength < parseint(provider[cardtype].validlength)) || (!$.inarray(cclength, provider[cardtype].validlength.split(','))))) {             triggernotification('x', 'your credit card number isn\'t long enough');             return false;         } else {             if ($('.credit-card input[name="cc_cvv"]').val().length < 3) {                 triggernotification('x', 'you must provide ccv');                 return false;             }         }     } else {         triggernotification('x', 'credit card type not recognized or accepted');         return false;     }     return true; }, 

i've included values of console.log() on 5th & 6th lines. reason, doesn't fail...

update

provider[cardtype].validlength either '16,13' or '16'

$.inarray( 16, ['16'] ); //=>-1 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -