Q:

Why is this telling me that my var is undefined?

I want to create an alert to force the user to enter a value greater than 0 into an input form before submitting.
Why is it telling me that my var is undefined?

function rollDice(bet) {
  bet = document.getElementsByName("startingBet").value;
  if (bet <= 0) {
    alert("You must place a bet");
    return false;
  }
}
<form action="luckysevens.html" onsubmit="rollDice()">
  <p>Starting Bet: $ <input type="number" name="startingBet" id="startingBet" /></p>
  <input type="submit" name="play" value="Play" />
</form>

A:

I don't see the reason to bet be undefined since you have assigned bet value. But obviously, the value of bet is undefined since you are using getElementsByName and it will will have an array-like value and you can not get value on this directly. You'll need to iterate through it. For simplicity you may use getElementsByName("startingBet")[0]. But I would suggest you to do the following.
Replace this:
document.getElementsByName("startingBet").value;

With this:
document.getElementById("startingBet").value;

