SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)

    HTML input name reads as array in JS

    I'm trying to create a subscribe/unsubscribe form for the newsletter system 12all. I don't want to use the auto-generated form.

    The only hitch to get everything working seems to be the input names. They look like this:

    Code:
    <form name="my_form" method="post" action="box.php" onsubmit="return validate_subscribe_form(this);">
    <input type="text" maxlength="100" size="25" value="" name="field[1,0]" />
    </form>
    In javascript, I have a form validator that needs to reference these names. It works fine when the input names are standard text, and not in this array format that the 12all webapp produces. Should I put quotes or something around the input names in javascript?

    Here's what the form validador code looked like before:

    Code:
    function validate_subscribe_form(thisform){
        var validcheck=true;
    
    if(!validate_required(thisform.organization,'valid_organization')){
            validcheck=false;
        }
    
    }
    Here's what I've tried:
    Code:
    if(!validate_required(thisform.'field[1,0]','valid_organization')){
            validcheck=false;
        }
    
    if(!validate_required(thisform."field[1,0]",'valid_organization')){
            validcheck=false;
        }
    Any ideas? Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thisform['field[1,0]']

  3. #3
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,617
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Awesome, that did the trick

    Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •