You can use a regex match to see if the string contains all uppercase letters:
var uppercaseletters = /^[A-Z]+$/;
if(data2.match(uppercaseletters)) {
document.write('hey');
} else {
document.write('nope');
}
2
solved Testing for uppercase, why is toUppercase() alphanumeric in javascript? [closed]