Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation messages overlay field name #24

Open
cliffmcmanus opened this issue Jan 28, 2018 · 4 comments
Open

Validation messages overlay field name #24

cliffmcmanus opened this issue Jan 28, 2018 · 4 comments

Comments

@cliffmcmanus
Copy link

I am developing a new app and love the visual for the float label. However when I add an asp-validation- the field name is overlay-ed. I would like the validation messages to appear under the field. I don't know if this is my lack of my knowledge of HTML/CSS or understanding of the usage of the add in. Here is an section of the cshtml file


@Html.EditorFor(m => m.Guarantor.FirstName, new {htmlAttributes = new {@Class = "form-control",
@Placeholder = @Html.DisplayNameFor(m => m.Guarantor.FirstName )}})
@Html.LabelFor(m => m.Guarantor.FirstName)

@tonystar
Copy link
Collaborator

@cliffmcmanus can you please share the screenshot? Also, generated markup would be helpful.

@cliffmcmanus
Copy link
Author

cliffmcmanus commented Jan 31, 2018 via email

@cliffmcmanus
Copy link
Author

cliffmcmanus commented Feb 1, 2018 via email

@b3nnee
Copy link

b3nnee commented Aug 26, 2018

I noticed @tonystar has not been able to treat this.

Here is a fix. Put this in a custom.css file or at the bottom of the bootstrap version of the floatinglabel css file. Tweak as needed.


.has-float-label .form-control:placeholder-shown:not(:focus)+label.error {
    font-size: 80%;
    opacity: 1;
    top: auto;
}

.has-float-label label.error {
    display: block;
    position: relative;
    top: auto;
    clear: both;
    left: auto;
    right: auto;
    margin: 5px;
    /*make this "left" if you wish and increase the bottom-margin/margin  so it does not clash with any floating labels below it (if any).*/
    text-align: right;
    font-size: 80%;
}

.has-float-label label.error::after {
    content: " ";
    display: block;
    position: relative;
    height: auto;
    top: auto;
    clear: both;
    left: auto;
    right: auto;
    font-size: 80%;
    z-index: -1;
}

My validation message class and element is different from yours, so factor that in but the content of the CSS is generally the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants