Skip to content

Commit

Permalink
Simple reset on validation error in iris picker
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Nov 1, 2017
1 parent 547bde0 commit c9f685f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions assets/js/admin/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@
event.stopPropagation();
$( '.iris-picker' ).hide();
$( this ).closest( 'td' ).find( '.iris-picker' ).show();
$( this ).data( 'original-value', $( this ).val() );
})

.on( 'change', function() {
if ( $( this ).is( '.iris-error' ) ) {
var original_value = $( this ).data( 'original-value' );

if ( original_value.match( /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/ ) ) {
$( this ).val( $( this ).data( 'original-value' ) ).change();
} else {
$( this ).val( '' ).change();
}
}
});

$( 'body' ).on( 'click', function() {
Expand Down

0 comments on commit c9f685f

Please sign in to comment.