html表单内容和css对齐问题
我有一个带有提交按钮和取消按钮的用户注册表单,
问题 1) 如果我在表单中使用 提交按钮
,当我单击取消按钮
时,它执行表单的操作,而不是返回主页并取消注册页面。
我们不能将这两个按钮放在一个表单中吗?
问题2)由于问题1,我在表单外部添加了取消按钮
并链接到主页,它按我的预期工作,但是,我需要这些屏幕同一行中的两个按钮
。
<div id="main-content">
<div id="login-container">
<form id="user-registration-form" method="POST">
// Some other fields, like username, etc.
<fieldset class="edit" id="submit-button-fieldset">
<input type="submit" id="submit-regiser"/>
</fieldset>
</form>
<fieldset id="Cancel-field">
<button id='cancel-registration' onclick=window.location.href='link-to-home'>Cancel</button>
</fieldset>
</div>
</div>
我需要将这些 #submit-regiser
和 #cancel-registration
放在屏幕的同一行中。这是针对移动浏览器的,因此应该遵守 XHTML
规则
提前致谢。
I have a user registration form with a submit button and a cancel button,
Problem 1) I can't have those two buttons inside the single form, if I have the cancel button inside the form with submit button
, when I click the cancel button
, it execute the action of the form instead of going to home and cancelling the registration page.
Can't we have these two buttons inside a single form..?
Problem 2) Because of Problem 1, I added the cancel button
outside the form and linking to the home page, it works as I expect, but, I need to have those two button
in the same row on the screen.
<div id="main-content">
<div id="login-container">
<form id="user-registration-form" method="POST">
// Some other fields, like username, etc.
<fieldset class="edit" id="submit-button-fieldset">
<input type="submit" id="submit-regiser"/>
</fieldset>
</form>
<fieldset id="Cancel-field">
<button id='cancel-registration' onclick=window.location.href='link-to-home'>Cancel</button>
</fieldset>
</div>
</div>
I need to have those #submit-regiser
and #cancel-registration
in the same row in the screen. And this is for mobile browser, so should obey XHTML
rules
Thanks in advanced.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

这就是预期的行为。取消按钮应该清除表单,而不是返回到之前的页面。
您仍然可以使用
That's the intended behavior. Cancel buttons are supposed to clear the form, not to take one back to what page ever.
Still you can do it this way using the
<button>
element: