Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    178
    Thanks
    138
    Thanked 0 Times in 0 Posts

    help with JQuery and Forms

    Hello,

    How would I go about amending the code below to only be only work on the form name "login"?

    the code below is not working for me =\ and im out of ideas.

    Code:
    <html>
    
    <head>
     <script src="http://code.jquery.com/jquery-latest.js"></script> 
    </head>
    
    <body>
    <script>
    $(document).ready(function(){
    $("login").bind("click keypress", function(evt) {
        var keyCode = evt.which || evt.keyCode;
        if (keyCode == 13) {
            alert("ENTER pressed");
        }
        });
    
        
    });
    </script>
    <form name="login">
        <input type="text" />
        <input type="submit" id="submit1" value="First" />
        <input type="submit" id="submit2" value="Second" />
    </form>
    </body>
    
    </html>
    Any help is greatly appreciated.

    Cheers,

    J

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    are you trying to write a submit function by chance? what is it you are trying to accomplish?

    also having 2 submit button in one form is generally not a good idea.

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Posts
    178
    Thanks
    138
    Thanked 0 Times in 0 Posts
    Hi Dan,

    You are right, I am trying to do a submit button with it.

    The two buttons are just there for an example only.

    If I can make this work with one of them that would be awesome.

    J


  •  

    Posting Permissions

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