second form action attribute not working - css

I have 2 form action below and whenever I click the 2nd form action (post /logout), the first action (get /journey) get triggered.
<form action="/journey" method="get"><input type="submit" value="Journey" />
<form action="/logout" method="POST"><input type="submit" value="Logout" />
The second action works if I didn't add in the /journey action.
Anyone can tell me what's wrong? Thanks.

try after closing form tags as shown below :
<div style="float:left">
<form action="/journey" method="get">
<input type="submit" value="Journey" />
</form>
</div>
<div>
<form action="/logout" method="POST">
<input type="submit" value="Logout" />
</form>
</div>

Related

HTML buttons on the same line

I have this html code which made in browser three buttons.How can I put the buttons on the same line?(they appear on different lines).
<form action="file:///C:/Users/andre/Desktop/home.html"/>
<input type="submit" value="Home" />
</form>
<form action="file:///C:/Users/andre/Desktop/players.html"/>
<input type="submit" value="Players" />
</form>
<form action="file:///C:/Users/andre/Desktop/league.html"/>
<input type="submit" value="League" />
</form>
input[type=submit]{cursor:pointer}
form input{float:left;margin:5px}
<form action="file:///C:/Users/andre/Desktop/home.html"/>
<input type="submit" value="Home" />
</form>
<form action="file:///C:/Users/andre/Desktop/players.html"/>
<input type="submit" value="Players" />
</form>
<form action="file:///C:/Users/andre/Desktop/league.html"/>
<input type="submit" value="League" />
</form>
form tag's default display value is block. If you make it inline-block, it will solve that problem.
<form style="display: inline-block;" action="file:///C:/Users/andre/Desktop/home.html">
<input type="submit" value="Home" />
</form>
<form style="display: inline-block;" action="file:///C:/Users/andre/Desktop/players.html">
<input type="submit" value="Players" />
</form>
<form style="display: inline-block;" action="file:///C:/Users/andre/Desktop/league.html">
<input type="submit" value="League" />
</form>
Just add following code
<style>
form { display : inline-block; }
</style>

How to add a bootstrap form element in asp.net content page

I am trying to add a bootstrap form in asp.net content page(.aspx). but it gives me an error regarding "Element form must not be nested with in a element form"
But i want to use the form element for a Login purpose in the page.
<div class="container">
<h2>Vertical (basic) form</h2>
<form>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" />
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<%-- --%>
</asp:Content>
Thanks in Advance
All asp webpages are already in a form, so you don't need the form tag, all you can do is instead of using, you can see the form tags at your main master page <form> you can use <div class="form"> hope this helps also for the best result
you should use CssClass instead of class in asp tags when adding the styling classes. e.g <asp:TextBox ID="TextBox14" runat="server" CssClass="form-control"></asp:TextBox>
you have simply use
<div class="container">
<h2>Vertical (basic) form</h2>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" />
</div>
<button type="submit" class="btn btn-default">Submit</button>
The message is clear.
Remove the extra form tags <form> and </form> from your code. Beside that your form did not post anywhere - use the asp.net form to post to code behind, you do not need other form there.

Login OnClick Event not firing

This is my first attempt at creating an asp.net website so please be kind. I'm attempting to fire a click event on a submit button in ASP.NET, the template I'm using has this html
<div id="lightbox"></div>
<div id="loginbox-panel">
<form action="#">
<fieldset>
<div class="frame">
<h4>TestSite</h4>
<small>Sign in to your account.</small>
<div class="clear"></div>
<input type="text" value="Username" class="input-text autoclear" />
<input type="password" value="Password" class="input-text autoclear" />
</div>
<div class="separator"></div>
<div>
<input type="submit" value="Sign in" class="input-submit float-right" />
Forgot your password?
</div>
</fieldset>
</form>
</div>
I believe the input type="submit" is client side but could be made to run a server side event using
<input type="submit" value="Sign in" class="input-submit float-right"
runat="server"
onserverclick="LoginButton_Click"/>
with code behind
protected void LoginButton_Click(object sender, EventArgs e)
{
//login handler
}
However, the event is not firing! Please can someone advise how I can get the LoginButton_Click event to fire
Thanks
Your form needs to be runat=server to be able to send the form back to the server and wire up the click event on the button.

Need help making form W3C compliant

I've styled a domain search form with CSS and DIV tags, but it's not W3C compliant since I separated the form tags. How can I get around this and still be able to style each component of the form?
<div class="reg-domain-txt">
<span>Register Your Domain Name Today!</span>
</div>
<div class="checkerform">
<form action="https://www.xhostcompanyx.com/clients/domainchecker.php" method="post">
<input type="hidden" name="token" value="xxxxxxxxx" />
<input type="hidden" name="direct" value="true" />
<input class="inputbox" type="text" name="domain" size="29" />
</div>
<div class="tldboxlist">
<select class="tldbox" name="ext">
<option>.com</option>
<option>.net</option>
<option>.org</option>
<option>.biz</option>
<option>.us</option>
<option>.info</option>
<option>.mobi</option>
<option>.me</option>
<option>.co</option>
<option>.tv</option>
<option>.pro</option>
</select>
</div>
<div class="domaincheckbutton">
<input class="domainbutton" type="submit" value="Search" />
</form>
</div>
Just put the start and end form tags outside of the divs.
Please explain why this will prevent you from styling?
The code you’ve posted isn’t valid because you’ve opened a <div> tag, then opened a <form> tag, then closed the <div> tag before closing the <form> tag. You can’t do that with any tags in HTML.
Here’s your HTML, corrected and indented — indentation really helps make these kinds of HTML errors more obvious:
<div class="reg-domain-txt">
<span>Register Your Domain Name Today!</span>
</div>
<div class="checkerform">
<form action="https://www.xhostcompanyx.com/clients/domainchecker.php" method="post">
<input type="hidden" name="token" value="xxxxxxxxx" />
<input type="hidden" name="direct" value="true" />
<input class="inputbox" type="text" name="domain" size="29" />
<div class="tldboxlist">
<select class="tldbox" name="ext">
<option>.com</option>
<option>.net</option>
<option>.org</option>
<option>.biz</option>
<option>.us</option>
<option>.info</option>
<option>.mobi</option>
<option>.me</option>
<option>.co</option>
<option>.tv</option>
<option>.pro</option>
</select>
</div>
<div class="domaincheckbutton">
<input class="domainbutton" type="submit" value="Search" />
</div>
</form>
</div>
I would remove the three DIVs. They are not necessary for content or styling. If you need to group together form elements, you should use the FIELDSET tag. Also, if you need to position the entire form, you can give the form an ID or a Class.

When label tag should be used over span/dev tags in html form?

When label tag should be used over span or dev in form?
Example:
option1-span:
<form action="">
<span>Name:</span><input type="text">
<input type="submit" />
</form>
option2-label:
<form action="">
<label>Name:</label><input type="text">
<input type="submit" />
</form>
option3-div:
<form action="">
<div style="display:inline;">Name:</div><input type="text">
<input type="submit" />
</form>
Thanks
This is what label tags are for:
<form action="">
<label for="txt">Name:</label><input type="text" id="txt" name="txt" />
<input type="submit" />
</form>
Then clicking on the label will focus on the input element.
The label tag is primarily used along with the for attribute. This aids in web accessibility of forms. For example
<form>
<label for="firstName">First name:</label>
<input type="text" name="firstName" value=""/>
</form>
By using the for tag, we can essentially associate the text "First Name:" with the input field having the name = "firstName".
Aside from that it has other attributes allowed but the span is more regularly used for styling markup.

Resources