Skip to main content

Forums

This topic contains 2 replies, has 0 voices, and was last updated by  brianatlarge 8 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #30228

    brianatlarge
    Member

    I’ve got several forms on one page and I want to validate whether or not one of the fields on the form that is being submitted is filled in or not.

    Basically my form looks like this:









    White Shirt
    Quantity:
    Price: $29




    So my thought process was, select THIS, which would be the submit button, then use closest() to go up the tree to the table, then go back down to .quantity, and get the value of that.


    function checkform() {
    alert($(this).closest('table').children('.quantity').val());
    }

    Unfortunately, the only thing I’m getting is “undefined”. What’s the proper way to traverse to get what I’m looking for?

    #79900

    jamygolden
    Moderator

    Try:

    function checkform() {
    alert($(this).closest('table').find('.quantity').val());
    }
    #79666

    brianatlarge
    Member

    That didn’t work.

    I also thought about changing it to .closest(‘form’), since table is on the same level as the submit button, but that didn’t make any difference. I also tried it with the .find() that you suggested, and still no luck.

    Any other suggestions?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

icon-link icon-logo-star icon-search icon-star