Skip to content

Commit

Permalink
Tests and docs for binding the validation to any DOM element
Browse files Browse the repository at this point in the history
  • Loading branch information
gmajoulet committed May 15, 2013
1 parent 5477580 commit bc78a4c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dist/parsley-standalone.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/parsley.extend.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/parsley.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ <h4>Properties</h4>
</table>
</td>
</tr>

<tr>
<td><code>data-bind</code></td>
<td></td>
<td>The attribute data-validate must be used on a form. However, if you want to bind the validation to another DOM element, just add this attribute and set it to <code>true</code></td>
<td></td>
</tr>
</tbody>
</table>
</section>
Expand Down
4 changes: 4 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@
<input type="text" id="luhn" data-luhn="true" />
<input type="text" id="americanDate" data-americandate="true" />
</form>

<div data-validate="parsley" data-bind="true">
<input type="text" id="bindNonFormInput" data-required="true" value="" />
</div>
</div>

<script type="text/javascript">
Expand Down
7 changes: 5 additions & 2 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ var testSuite = function () {
expect( $( '#hidden' ).hasClass( 'parsley-validated' ) ).to.be( false );
expect( $( '#hidden' ).parsley( 'validate' ) ).to.be( null );
} )
it ( 'Should bind a DOM element with data-bind value set to true', function () {
expect( $( '#bindNonFormInput' ).hasClass( 'parsley-validated' ) ).to.be( true );
} )
} )

/***************************************
Expand Down Expand Up @@ -700,12 +703,12 @@ var testSuite = function () {

$( '#scenario-multiple-errors-and-required' ).val( '[email protected]' );
expect( $( '#scenario-multiple-errors-and-required' ).parsley( 'validate' ) ).to.be( false );
expect( $( 'ul#' + fieldHash + ' li' ).length ).to.be( 1 );
expect( $( 'ul#' + fieldHash + ' li' ).length ).to.be( 1 );
expect( $( 'ul#' + fieldHash + ' li' ).eq( 0 ).hasClass( 'rangelength' ) ).to.be( true );

$( '#scenario-multiple-errors-and-required' ).val( 'foo' );
expect( $( '#scenario-multiple-errors-and-required' ).parsley( 'validate' ) ).to.be( false );
expect( $( 'ul#' + fieldHash + ' li' ).length ).to.be( 2 );
expect( $( 'ul#' + fieldHash + ' li' ).length ).to.be( 2 );
} )
it ( 'Test keyup scenario for non-required field', function () {
// do not pass the 3 chars min trigger
Expand Down

0 comments on commit bc78a4c

Please sign in to comment.