How do I get input tag text to align to the top? - asp.net

I am building a Razor Pages web app and I added the CRUD features to it. On my Create page, there's a form to create entries which uses input tags. One of those fields is for comments so obviously it needs to be larger. So I added a width and height styles to it. However, the text only appears in the middle of the comment field and when the text reaches the end of the field, it doesn't wrap.
Create.cshtml.cs
#page
#model HSLogApp.Pages.HSLogs.CreateModel
#{
ViewData["Title"] = "Create";
}
<h2>Create</h2>
<h4>Log</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
....
....
<div class="form-group">
<label asp-for="Log.Comment" class="control-label"></label>
<input asp-for="Log.Comment" class="form-control" style="height:250px; width:500px; vertical-align:top; white-space: pre-wrap;"/>
<span asp-validation-for="Log.Comment" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</form>
</div>
</div>
<div>
<a asp-page="Index">Back to List</a>
</div>
#section Scripts {
#{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
How can I get the cursor to flush to the top and how do I get it to wrap?

For multiline input use a textarea element.
There is an ASP.NET Core Tag Helper for it. The usage will be mostly the same as an input. Here is your example with a textarea.
<div class="form-group">
<label asp-for="Log.Comment" class="control-label"></label>
<textarea asp-for="Log.Comment" rows="3" class="form-control"></textarea>
<span asp-validation-for="Log.Comment" class="text-danger"></span>
</div>
Now the use of the rows attributes in the textarea to specify the number of rows of text.

Related

bootstrap container contents in the left side of the screen?

I am using bootstrap and I have a container with a login form.
However, I want to align this form to the left side of the page. However, using float left makes it look ugly and also makes the form input smaller, as you can see here:
http://codepen.io/anon/pen/xZGOjR
<div class="container">
<div class="form-container">
<form class="form-horizontal" name="form" role="form" >
<fieldset>
<div class="form-group">
<div class="btn-icon-lined btn-icon-round btn-icon-sm btn-default-light">
</div>
<input type="email" class="form-control input-lg input-round text-center" placeholder="Email" ng-model="user.email" name="email" ng-required autofocus>
</div>
<div class="form-group">
<div class="btn-icon-lined btn-icon-round btn-icon-sm btn-default-light">
</div>
<input type="password" class="form-control input-lg input-round text-center" placeholder="Password">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-lg btn-round btn-block text-center">Log in</button>
</div>
</fieldset>
</form>
</div>
</div>
How can I make it so the form input is to the left side without looking ugly?
To do it the bootstrap way. You could add a column width to the form <div class="form-container text-center col-xs-3">
Here is your original example tidied up a bit http://codepen.io/anon/pen/XXbKvN
Bootstrap uses a 12 column grid system so that everything is nicely laid out on the page. For more info have a look here http://getbootstrap.com/css/#grid-options
You can use width: 350px; to the .form-container class.
It can better, if you can upload your design. screenshot.

Kendo UI validation message breaks bootstrap layout

I have a form to collect user information which is designed using bootstrap. I am using Kendo UI validation for validating user input.
This is a portion of the form.
Html for the first line of the form.
<div class="col-lg-4">
<div class="form-group">
<label for="FirstName">First Name:</label>
<div class="input-group">
<input type="text" id="FirstName" name="FirstName" class="form-control" placeholder="First name" />
<span class="input-group-addon" id="FirstNameAddon">
<input type="checkbox" id="unkFirstName" value="Unknown" />Unknown
</span>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="form-group">
<label for="LastName">Last Name:</label>
<div class="input-group">
<input type="text" id="LastName" class="form-control" placeholder="Last name" />
<span class="input-group-addon" id="LastNameAddon">
<input type="checkbox" id="unkLastName" value="Unknown" /> Unknown
</span>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="form-group">
<label for="Initials">Initials:</label>
<div class="input-group">
<input type="text" id="Initials" class="form-control" placeholder="Initials" />
<span class="input-group-addon" id="InitialsAddon">
<input type="checkbox" id="unkInitials" value="Unknown" /> Unknown
</span>
</div>
</div>
</div>
Everything is fine with the layout if there is not validation message. But when there is a validation message layout goes ugly.
How can I make the validation message to span across both input and add-on? How to make the validation message to float on top of the controls so that it won't effect the controls next to it even if message is longer?
Here is the Kendo Dojo http://dojo.telerik.com/ihANu that replicates the issue. Look in full screen http://runner.telerik.io/fullscreen/ihANu
Thank you.
You could try taking it out of the normal flow and overlaying it ontop of the screen so that it didn't disrupt the other elements by adding position: absolute
.k-widget.k-tooltip-validation.k-invalid-msg {
position: absolute;
top: 100%;
left: 0;
}
Demo in Dojo
KyleMit answer is good and one way to do it. I prefer using validator message custom positioning which is Kendo UI validator functionality. U can place validator message where ever u want using single line of html. Just place input id for data-for attribute to connect it to right input element.
<span class="k-invalid-msg" data-for="input-id"></span>

Styling Grails g:form and g:submit

My Grails (2.4.2) app has a simple form on one of its GSPs, that uses Bootstrap for styling:
<!DOCTYPE html>
<html>
<head>
<!-- Head omitted for brevity. -->
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-8 text-center">
<h1 class="strong-primary">Sign in to continue to MyApp.</h1>
</div>
<div class="col-md-4 text-center">
<form role="form">
<div class="form-group">
<input type="email" class="form-control" id="signin-email" placeholder="Your email">
</div>
<div class="form-group">
<input type="password" class="form-control" id="signin-password" placeholder="Password">
</div>
<button type="submit" class="btn form-control btn-lg btn-success">Sign in</button>
<div class="form-group" style="text-align: left;">Need help?</div>
</form>
</div>
</div>
</div>
</body>
</html>
When the user clicks the "Sign in" button, the FizzController#signin() action should be executed. I am tempted to change the GSP form to something like:
<g:form controller="fizz" action="signin">
<div class="form-group">
<input type="email" class="form-control" id="signin-email" placeholder="Your email">
</div>
<div class="form-group">
<input type="password" class="form-control" id="signin-password" placeholder="Password">
</div>
<g:submitButton name="submit" value="Sign in" />
<div class="form-group" style="text-align: left;">Need help?</div>
</g:form>
But then I lose the form role="form" declaration and the styling (btn form-control btn-lg btn-success) classes on the button.
How can I merge <g:form> and <g:submitButton> with my Bootstrap stylings?
There is nothing keeping you from adding additional attributes and values to the output from the standard <g:> tag library.
For example:
<g:form controller="fizz" action="signin" role="form" class="someClass">
The above will include the two additional attributes role and class as they appear. This holds true for almost all (if not all) of the standard tags in Grails.
If you want to look and see how this is actually implemented in the outputAttributes, you can review the source code for the built in forms tag library.
Applying styles to a dynamically generated page can be difficult coming from styling static HTML pages. A problem I ran into was correctly applying styles to my rendered templates in Grails. If your project uses a rendered template to display a form remember to apply the Bootstrap .form class to the parent view's <g:form> tag as noted in #Joshua Moore's answer.
Styles would look similar to:
<g:form id='myId' class='form-horizontal'>
<g:render template='myFormTemplate' model='yourModelInformationHere'/>
</g:form>
Done this way, the .form-group class can be used on the underlying template and since the .form-horizontal class is declared already the rendered page will be correct.

Bootstrap 3: Form styles failing

Here is my jsFiddle with full code example.
I would like:
The entire "page content" container (that is, the <h1> that starts "Sign in to..." as well as the entire <form> element) to be centered in the screen; and
The "Need help?" link needs to be left aligned, aligning with the submit button's left side
I am trying to style center the container via text-center. I am trying to align the link via text-left. Neither are working:
<div class="container">
<div class="row">
<div class="col-md-8 text-center">
<h1 class="strong-primary">Sign in to continue to Audit<b>Cloud</b>.</h1>
</div>
<div class="col-md-4 text-center">
<form role="form">
<div class="form-group">
<input type="email" class="form-control" id="signin-email" placeholder="Your email">
</div>
<div class="form-group">
<input type="password" class="form-control" id="signin-password" placeholder="Password">
</div>
<button type="submit" class="btn form-control btn-lg btn-success">Sign in</button>
<div class="form-group">Need help?</div>
</form>
</div>
</div>
</div>
Any ideas?
You need to apply text-align:left; to the containing <div>. Instead of class="text-left, use style="text-align:left;. I put those changes into your fiddle:
http://jsfiddle.net/fjL4f2ew/1/

twitter bootstrap - creating a two panel modal

Does anyone have any ideas of how to create a two panel modal. So for example one side would be a login form or something and the other side would be a list of what users get. Or one side would be a physical contact information div and the other side would be an email contact form. I tried to do two divs under the modal div tag and have one pull-left the other pull-right with each span5 or span6 but it didn't work. I ask because I have this issue. Also can anyone tell me why my contact form has so much space between the label and the input box? Go to scoopclassifieds.com (not trying to plug my site, can't post pics yet) and click contact us. I have placed the html mark up blow
<div class="modal hide fade" id="contactForm" aria-hidden="true">
<div class="modal-body">
<form action="" method="post" class="form-horizontal">
<div class="control-group">
<label class="control-label">Email:</label>
<div class="controls">
<input type="text" name="email" id="email" class="input" />
</div>
</div>
<div class="control-group">
<label class="control-label">Subject:</label>
<div class="controls">
<input type="text" name="subject" id="subject" class="input" />
</div>
</div>
<div class="control-group">
<label class="control-label">Message:</label><br/><br/>
<div class="controls">
<textarea rows="5" class="input span4" name="message" id="message"></textarea>
</div>
</div>
<div class="control-group"><div class="controls"><input type="submit" name="contactUs" id="contactUs" class="btn" value="Contact Us" /></div></div>
</form>
</div>
</div>
Sorry if the code is so horribly formatted. I used cpanel text editor to develop it. I know its a bad idea but I had to do it as fast as possible to provide a live example.
Try putting a row-fluid inside the modal-body, and then 2 span6 inside that..
<div class="modal-body">
<div class="row-fluid">
<form class="span6">
</form>
<div class="span6">
</div>
</div>
</div>
You may also want to increase the default width of the modal..
.modal {
width:45%;
left:45%;
}
Demo on Bootply: http://bootply.com/69517

Resources