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
Post a Comment