Q:

JS function not displaying anything

I have made a function and captured the value of a textbox. On a button click, it should alert the value.
The code is:
function substitute (argument) {
    var myVal=document.getElementById('myTextBox').value();
    alert(myVal);
    if (myVal.length==0) {
        alert('Empty Textbox');
    };
}

It is then executed using this:
<input type="button" name="Button" value="Click Me" onclick="substitute();">

But nothing happens. Please tell me where am I doing it wrong.

A:

You have a few errors:

.value() is not a function: use .value
You  don't need that semicolon at the end of the if statement
Your text box might not have the id that you're referring to: make sure that you have id="myTextBox" in the opening tag
While it won't cause any errors, your function definition lists a parameter, but you do not pass one when you call it.

Always check your browser console for errors if nothing is happening. Always.
function substitute () { // Parameter "argument" is not necessary
    var myVal=document.getElementById('myTextBox').value; //.value, not .value()
    alert(myVal);
    if (myVal.length==0) {
        alert('Empty Textbox');
    }; // You don't need this semicolon
} // You were missing this curly brace

Demo

A:

value is not a function, it's a property, therefore:
var myVal=document.getElementById('myTextBox').value;

As you're brand new to JS, I'll give you a piece of advice: If you want to manipulate the DOM, use jQuery.

