8000 Demo: Add sample code for Bootstrap 4 usage by gwhenne · Pull Request #2173 · jquery-validation/jquery-validation · GitHub
[go: up one dir, main page]

Skip to content

Demo: Add sample code for Bootstrap 4 usage #2173

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

Merged
merged 2 commits into from
Jun 20, 2018
Merged

Demo: Add sample code for Bootstrap 4 usage #2173

merged 2 commits into from
Jun 20, 2018

Conversation

gwhenne
Copy link
Contributor
@gwhenne gwhenne commented May 29, 2018

Ref #2131.

Simple page showing how to use jquery-validation with Bootstrap 4.

Copy link
Member
@Arkni Arkni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gwhenne,

Thanks a lot for your contribution.

This looks good so far, however I left some comments in order to address some minor issues.

Also, do you think you can add an example with feedback icons like the one in Bootstrap v3 example?

<body>
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

col-sm-offset-2 => offset-sm-2

<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<div class="page-header">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page-header => border-bottom mb-4 mt-4 pb-2

},
errorElement: "em",
errorPlacement: function ( error, element ) {
// Add the `help-block` class to the error element
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help-block => invalid-feedback

error.addClass( "invalid-feedback" );

if ( element.prop( "type" ) === "checkbox" ) {
error.insertAfter( element.parent( "label" ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

element.parent( "label" ) => element.next( "label" )

}
},
highlight: function ( element, errorClass, validClass ) {
$( element ).parents( ".col-sm-5" ).addClass( "is-invalid" ).removeClass( "is-valid" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove .parents( ".col-sm-5" ), it's not needed here.

$( element ).parents( ".col-sm-5" ).addClass( "is-invalid" ).removeClass( "is-valid" );
},
unhighlight: function (element, errorClass, validClass) {
$( element ).parents( ".col-sm-5" ).addClass( "is-valid" ).removeClass( "is-invalid" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove .parents( ".col-sm-5" ), it's not needed here.

<div class="form-check">
<label>
<input type="checkbox" id="agree" name="agree" value="agree" class="form-check-input"/>Please agree to our policy
</label>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to:

<input type="checkbox" id="agree" name="agree" value="agree" class="form-check-input"/>
<label class="form-check-label">Please agree to our policy</label>

@gwhenne
Copy link
Contributor Author
gwhenne commented Jun 19, 2018

@Arkni - I just uploaded code with your suggestions - thank you!

I didn't add Bootstrap 3 style feedback icons to the sample. Bs3 used Glyph icons to do this, which are not in Bs4.

From https://www.quackit.com/bootstrap/bootstrap_4/differences_between_bootstrap_3_and_bootstrap_4.cfm

Validation styles are not available for Bootstrap 4 forms. Use custom Bootstrap form validation messages instead.

@Arkni
Copy link
Member
Arkni commented Jun 20, 2018

I applied the changes you pushed (found in branch patch-2 in your fork) manually and pushed them to the branch patch-1, because when you update the file using GitHub interface, it creates a new branch for each update, that's why I didn't see the changes here.

Thanks a lot for your contribution :)

@Arkni Arkni merged commit 349fc57 into jquery-validation:master Jun 20, 2018
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

Successfully merging this pull request may close these issues.

2 participants
0