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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -