Email and Password form in one row with bootstrap - html

I started bootstrap very recently. I want to create email/ password validation in one row on my rails app:
email? | password? | OK
Right now, I have a code working for just an email and OK button in one row:
email? | OK
<div class="col-lg-12 text-center v-center">
...
<form class="col-lg-12">
<div class="input-group input-group-lg col-sm-offset-4 col-sm-4">
<input type="text" class="center-block form-control input-lg" title="Enter your email." placeholder="email?">
<span class="input-group-btn"><button class="btn btn-lg btn-primary" type="button">OK</button></span>
</div>
</form>
</div>
and
.v-center {
margin-top:7%;
}
I tried adding a password on the code above:
...
<div class="input-group input-group-lg col-sm-offset-4 col-sm-4">
<input type="text" class="center-block form-control input-lg" title="Enter your email." placeholder="email">
<input type="text" class="center-block form-control input-lg" title="Enter your password." placeholder="password">
<span class="input-group-btn"><button class="btn btn-lg btn-primary" type="button">OK</button></span>
...
But it ended up looking like this:
email?
| OK
password?
What is missing?

It looks like bootstrap's .center-block has display: block; in it. If you want elements to appear side-by-side, they generally need a display of inline or inline-block in the css (there are a few other ways, but both those are arguably the most common/simplest).

Here is code for this: The trick is to use "form-inline" class in the form tag
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">Name</label>
<input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
</div>
<div class="form-group">
<label for="exampleInputEmail2">Email</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe#example.com">
</div>
<button type="submit" class="btn btn-default">Send invitation</button>
</form>

Related

How to perform validations in angular2

I am trying to perform validations to my fileds in such a way that when i click on submit button it must show error to fields which are empty.Can anyone please help me .............
<div *ngFor="let detail of details" class="nopadding col-sm-12">
<form [formGroup]="form" (ngSubmit)="onSubmit(form.value)" class="nobottommargin col-sm-12 formpaddingcss" name="template-contactform" novalidate="novalidate">
<div class="form-process"></div>
<div class="col_half">
<label for="template-contactform-name">First Name <small>*</small></label>
<div class="input-group divcenter">
<span class="input-group-addon noradius"><i class="icon-user iconcolorcss"></i></span>
<input type="email" data-toggle="tooltip" data-placement="top" title="Enter Firstname!" name="widget-subscribe-form-email" class="form-control required email formcontrolheight" [formControl]="form.controls['firstname']" [(ngModel)]="detail.firstname" placeholder="First Name" aria-required="true">
</div>
</div>
<div class="clear"></div>
<div class="col_full">
<button class="button button-blue button-mini bottommargin-sm pull-right text-right" type="submit">Save</button>
</div>
<div class="clear"></div>
</div>
Try this for simple validations....
<input type="email" title="Enter Firstname!" class="form-control required email formcontrolheight" [(ngModel)]="detail.firstname" placeholder="First Name" aria-required="true">
<span *ngIf="clicked && !detail.firstname || !detail.firstname.trim()" class="error">Error Its empty</span>
<button (click)="clicked = true"></button>
I don't its correct or not but this works fine with me. Refer this code:
<form id="discussion_form" name="discussion_form" ng-submit="addDiscussion(discussion_form.$valid)" novalidate>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="dis_title">Topic<span>*</span></label>
<input type="text" id="dis_title" class="form-control" name="dis_title" placeholder="e.g., about independence day celebration." required ng-model="discussionDetails.dis_title">
<label for="dis_title" class="form_errors" ng-show="discussion_form.dis_title.$invalid && !discussion_form.dis_title.$pristine">Please enter a discussion topic</label><!--To show error msg-->
</div>
</div>
</div>
<button type="submit" class="btn btn-primary pull-right" ng-disabled="discussion_form.$invalid">Submit</button>

Form-control will not adjust size of input

I am looking to create a simple signup form, but for some reason with my code the input does not adapt to bootstraps form-control-lg class so it will not match the size of my button when I am using default bootstrap CSS, can anyone help?
<div class="container">
<form class="form-inline">
<div class="form-group">
<div class="row col-md-5">
<input class="form-control form-control-lg" type="url" placeholder="Your Site URL">
</div>
</div>
<button type="submit" class="btn btn-success btn-lg" id="urlInput">TRY IT NOW</button>
</form>
</div>
Try adding the input-lg class to your input
<input class="form-control input-lg" type="url" placeholder="Your Site URL">
You can try using form-group-lg on the parent div instead
<div class="form-group form-group-lg">
<div class="row col-md-5">
<input class="form-control" type="url" placeholder="Your Site URL">
</div>
</div>

2 form elements and one link from a Not working on mobile

I have a login form on a site that is using bootstrap. On desktop there is no problem. But on mobile devices the button doesn't work nor does the checkbox. There is also a link for the forgotten password but that doesn't work on mobile either.
<div class="col-md-4 col-xs-8">
<form method="post">
<div class="row">
<div class="input-group col-md-12">
<input type="text" class="form-control" style="margin-bottom:10px;" placeholder="User Name" aria-label="User Name" name="username"/>
<input type="hidden" value="true" name="login_now"/>
</div>
<div class="col-md-12 input-group">
<input type="password" class="form-control" placeholder="Password" aria-label="Password" name="password"/>
<span class="input-group-btn">
<button role="button" class="btn btn-blue" type="submit" aria-label="Log In" name="login_button">Log In</button>
</span>
</div>
<div class="col-md-12">
<input type="checkbox" name="save-password" />
Save Password (do not check box if using a public computer)
<a class="password-link" href="forgot_password.php">Forgot Password?</a>
</div>
</div>
</form>
</div>
I have no idea why this isn't working on mobile, but is working on desktop
So the problem seemed to have been the col-xs-8 at the top. It seemed to have caused the input to overlap the button

Bootstrap input group addon not inline

This is my code: http://www.bootply.com/iR1SvOyEGH
<form>
<div class="form-group">
<label for="inputEmail">Company Name</label>
<input type="text" class="form-control">
<span class="input-group-addon">.test.com</span>
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
My understanding is the input-group-addon should sit inline with the input box and be to the right but instead it sits below the input box taking up 100% width.
Can anyone please tell me where I have gone wrong.
The Bootstrap documentation states that the input-group-addon class must be used within a input-group, while you are using a form-group.
<form>
<label for="inputEmail">Company Name</label>
<div class="input-group">
<input type="text" class="form-control">
<span class="input-group-addon">.test.com</span>
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
See this for a demo: http://jsfiddle.net/TLtQU/3/
EDIT: The input-group should not include the label, the label should be outside of the input-group for proper results.

BootStrap 3 Alignment of controls

I want to align TextBox which will be used as Searchbox and button.
Problem is when I use inline form class on div the textbox is loosing its width.
<div class="col-lg-6">
<input type="text" id="test" name="city" class="form-control input-lg" placeholder="E.g. Manchester">
<div class="form-inline">
<div class="form-group ">
<input type="text" id="city" name="city" class="form-control input-lg" placeholder="E.g. Manchester">
<input type="button" value="Search" class="form-control btn-lg"/>
</div>
</div>
</div>
what I'm missing here..
here is a good solution for you:
Screenshot:
Code:
<div class="form-group">
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="E.g. Manchester" />
</div>
<div class="input-group">
<input type="text" class="form-control" placeholder="E.g. Manchester" />
<span class="input-group-btn">
<button class="btn btn-default" type="button">Search</button>
</span>
</div>
Result:
http://jsfiddle.net/j9EdZ/
You might be best using the col-md-* values here, e.g.:
<div class='col-lg-6'>
<form class='form'>
<div class='row'>
<div class='form-group'>
<div class='col-md-10'>
<input class='form-control input-lg' type='text' placeholder='E.g. Manchester'>
</div>
<div class='col-md-2'>
<input type='button' class='form-control btn btn-block' value='Search'>
</div>
</div>
</div>
</form>
</div>
Text-box is not loosing its width you can check here.
CODE : http://jsfiddle.net/Jaysinh/awYm3/
As per the Bootstrap documentation of Form you have to set the width of the element. Default is 100 % wide.
Requires custom widths
Inputs, selects, and textareas are 100% wide by default in Bootstrap. To use the inline form, you'll have to set a width on the form controls used within.
Here, check this out.
Demo
HTML
<div class="col-lg-6">
<form class="form-horizontal" role="form">
<div class="form-group">
<input type="text" id="test" name="city" class="form-control input-lg" placeholder="E.g. Manchester" />
</div>
<div class="form-inline">
<div class="form-group ">
<input type="text" id="city" name="city" class="form-control input-lg" placeholder="E.g. Manchester" />
<input type="button" value="Search" class=" btn btn-lg btn-default" />
</div>
<div class="form-group "></div>
</div>
</form>
</div>