Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking textbox if it's empty in Javascript

Tags:

I wrote a simple html file with a textbox and submit button, and it generates and document.write's a response dependant on what you submit. I want to have it generate a response saying to enter content if the box is empty. The textbox's id is chatinput, so I have the following the code in the beginning

    var chatinput_box=document.getElementById('chatinput');
    var chatinput=chatinput_box.value;

Then a have a conditional, although I can't get it to work correctly; I've tried

    if(chatinput==""){}
    if(chatinput.length=0){}
    if(chatinput=null){}

and others but none have worked correctly. Does anyone have another idea?