Home Ask Login Register

Developers Planet

Your answer is one click away!

Zoker February 2016

Jquery submit() does not work like pressing submit button

I'm trying to build a auto-login button for my demo system (phpBB forum).

This should automatically enter the login details and then submit the login form:

$('#autologin').click(function () {
    $('#navloginform input[name="username"], #navloginform input[name="password"]').val('demo');

The inserting of the fields works, but submitting the form does not login the user. I also tried to fill the fields myself and then submitted the form in the console, but this does not work either. Pressing the submit button works as expected.

Can somebody help me?

edit: Solved it with: $('#navloginform button[type="submit]').trigger('click');


Zoker February 2016

Solved it with: $('#navloginform button[type="submit]').trigger('click');

John_Dean February 2016

That's good that you solved it. Your problem was that you used the same ID for more that one element. as rule: ID's have to be unique. If you just changed the submit button id to... #submitBtn (for example) then
$(" #submitBtn ").trigger('click');

Post Status

Asked in February 2016
Viewed 1,876 times
Voted 13
Answered 2 times


Leave an answer

Quote of the day: live life