Submit your work by clicking enter on the PHP and Javascript login page

I'm new to Javascript and I'm sure it's easy to fix, but I can't figure it out.

I am using a slightly modified version of the code from this page and I want to make the form work by entering information and clicking a button instead of clicking a button.

FYI I've read this thread and can't work out my own answer from there. I tried changing the type to "submit" from "button" but then login didn't work. I also tried changing "onlick" to "onsubmit" and had the same problem.

+1


source to share


3 answers


Use submit type but change onclick to onclick="loginFunction(); return false;"



return false

stops the submit button from actually completing the submit.

+4


source


If you want to submit the form by clicking a button instead of typing, then you don't need to use input type = "submit" instead, you can use input type = 'button' and set the onclick function in that as input type = "button" onclick = "my_func ( ) ", and in the definition of this my_func function, you can use document.formname.submit () to submit the form. hope this works for you.



+1


source


Set the "tab index" property for your html elements so that your button has the highest index (or one after it after the last html element).

-1


source







All Articles