arrays - Testing for uppercase, why is toUppercase() alphanumeric in javascript? -


how isolate touppercase() disregard numbers live code

var data = 'lol'; var data2 = '1 2 3 4';  if(data2 === data2.touppercase()) {   document.write('hey'); }else {   document.write('nope'); } 

both write hey document!

why in javascript touppercase() think numbers uppercase letters? best way test uppercase not numbers also?

you can use regex match see if string contains uppercase letters:

  var uppercaseletters = /^[a-z]+$/;     if(data2.match(uppercaseletters)) {       document.write('hey');   }  else {       document.write('nope');   } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -