I have a function that's supposed to check the length of a Tweet input box and make display a message depending on weather the max characters are exceeded or not. But when i run it, the if else loop only runs the "else" part no matter how many characters have been typed.

My Code:

Code JavaScript:
function checkTweet() {
	var maxLength = 140;
	var button = document.getElementById('submit');
	var tweetLength = document.getElementById("name");
	button.onclick = function () {
		if (tweetLength.length <= maxLength) {
			alert("Tweet Submitted");
		} else {
			alert("You have to many characters!");