SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot ameerulislam's Avatar
    Join Date
    Jul 2011
    Posts
    145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    hitting enter not submitting my form!

    Hi,

    when I hit enter on my site after hitting enter it's not submitting the form. Only clicking on login works. What could be the issue?

    this is the site..
    Code:
    http://www.organicsolutionsgroup.com/metronic1.4/login.php

  2. #2
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    323
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I noticed this error on your submit button:

    Code:
    <input type="submit" value="Login" name="login" class="btn green pull-right />
    You forgot to close the class attribute. Fixing that may help.

  3. #3
    SitePoint Zealot ameerulislam's Avatar
    Join Date
    Jul 2011
    Posts
    145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks but it didn't work that way. However I noticed there is a javascript at the end. that's preventing it. Removing them works but I'm looking for ways to keep them while making it work if that's possible.

    Quote Originally Posted by Patche View Post
    Hi,

    I noticed this error on your submit button:

    Code:
    <input type="submit" value="Login" name="login" class="btn green pull-right />
    You forgot to close the class attribute. Fixing that may help.

  4. #4
    SitePoint Zealot ameerulislam's Avatar
    Join Date
    Jul 2011
    Posts
    145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    it appears this piece of code is responsible for preventing login with keyboard enter button. But if I'm not mistaking this code suppose to help keyboard enter button?


    Code:
     $('.login-form input').keypress(function (e) {
    	            if (e.which == 13) {
    	                if ($('.login-form').validate().form()) {
    	                    $('.login-form').submit();
    	                }
    	                return false;
    	            }
    	        });

  5. #5
    SitePoint Zealot ameerulislam's Avatar
    Join Date
    Jul 2011
    Posts
    145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I figured the problem was that I had value="Login" on my form which was the root of all problems. Although I didn't get it why that can be a problem..

  6. #6
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    So this is code you've found?

    if ($('.login-form').validate().form()) {
    $('.login-form').submit();

    This only allows form submission if validation returned true. Then return false (should have been preventDefault probably). of course if you don't even have ths validate() function or whatever is supposed to do validation, it'll never become true.

    This should have been set on the submit event rather than listening only for a keypress. All input methods would normally trigger a submit event and that's the only thing that makes sense to me in this context.

    Though I've also seen people try to prevent hitting Enter in the middle of a form from accidentally submitting an incomplete form. IE is (or was, not sure anymore) the only browser that forced users to first focus on the submit button before Enter worked. Lots of people complained over the years that they couldn't just hit enter on simple forms like logins, but I agree with IE's behaviour.


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
  •