Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript My form reloads with onSubmit returning false

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29688
    dcp3450
    Participant

    I know this probably staring me in the face but:

    I have a basic for with a for header of:

    Code:

    the js looks at each input using: document.getElementById("name"). If it sees that the input is blank it colors the input yellow, selects it, and give is focus. Pretty simple, I use it on another form that has different inputs:

    Code:
    if(name == “”)
    {
    document.getElementById(“name”).style.backgroundColor = “yellow”;
    document.getElementById(“name”).select();
    document.getElementById(“name”).focus();
    return false;
    }

    I literally copied that from another function (just changed the variable and id to name). When I submit I can see it take the blank input yellow, then it reloads the whole form. My other forms work fine.

    Any ideas?

    #80170
    dcp3450
    Participant

    Turns out you shouldn’t get in a hurry and use a preset keyword as you input id name :::headdeask:::

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.