Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This should happen automatically, as long as the two forms are actually separate forms. In other words, there should be two separate <code>&lt;form&gt;</code> elements, one for login and one for registration.</p> <p><strong>Edit:</strong></p> <p>Browsers determine which submit button to "press" based on the form that has focus. If there are multiple submit buttons in a single form, which sounds like the case here, the browser will submit using the first submit button that it finds. I know of no way to get around that behavior.</p> <p>You're really asking how to perform one of two actions with a single form, which kind of breaks the form model: a form is designed to perform an action (GET or POST) on a single URL. I can think of one way to work around this behavior, but it is not particularly clean.</p> <p><strong>Suggestion:</strong></p> <p>I made a crude drawing of what I'm talking about. You basically add two radio buttons to the top of the form, one for login and one for registration. Underneath those you have two fieldsets, one with fields for login and one with fields for registration. The form has a single submit button.</p> <p><a href="http://img220.imageshack.us/img220/5923/boardc.jpg" rel="nofollow noreferrer">Click to view full size image http://img220.imageshack.us/img220/5923/boardc.th.jpg</a></p> <p>Users without Javascript will check the appropriate radio button and fill in the appropriate set of fields. Users with Javascript have a better experience. If the login radio button is checked, hide the registration fieldset. If the registration radio button is checked, hide the login fieldset.</p> <p>With proper styling, you can make it look nice. Your logic would have to check the radio button field's value to determine what action to take, but that shouldn't be too hard.</p> <p>That's all I can come up with, given the single form limitation. This might not be a viable solution at all, depending on your other constraints, but it's all I've got. Good luck, and let me know if you have any questions about what I've discussed!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload