Question: I have an textarea on a webpage, and I want to have a border around it when the string is empty. But it only works if I put something into the text and then delete it again. How can I make the border visible before I write in the textarea? Here is the code:

```
$("#message-box").on("keyup", function(){
    var charCount = $("#message-box").val().length;
    console.log("charCount");
    $("#char-count").html(charCount);

    if (charCount === "") {
      $("#message-box").css("border", "10px solid red");
    }else{
      $("#message-box").css("border", "");
          //event listener
      $("#submitbutton").on('click', function() {
        var comment = $("#message-box").val();
        $("#visible-comment").html(comment);
        $("#message-box").hide();

        console.log(comment);
        return false;
      });
    };
};

```

Answer: 
Please check you have some syntax errors. 

`$("#message-box").on(` this section is not closed with `);`

Also seperate the event `$("#submitbutton").on('click', function()` 

also `charCount = $("#message-box").val().length;` will return a number even if the text area is empty it give `0`. so you need to check it as

`if (charCount==0)`

So your final code become 

```
$("#message-box").on("keyup", function(){
    var charCount = $("#message-box").val().length;
    console.log("charCount");
    $("#char-count").html(charCount);

    if (charCount==0) {
      $("#message-box").css("border", "10px solid red");
    }else{
      $("#message-box").css("border", "");
          //event listener
    };
});

$("#submitbutton").on('click', function() {
var comment = $("#message-box").val();
$("#visible-comment").html(comment);
$("#message-box").hide();

console.log(comment);
return false;
});

```

<https://jsfiddle.net/tintucraju/08dp6ra5/2/>
I think your test doesn't work if there's no value previously inserted.

You could do

```
if ($("#message-box").val() == undefined || $("#message-box").val().length == 0)

```

instead of

```
if (charCount === "") {

```

to also check if the value exists at first.