Skip to content

Commit

Permalink
Prevent invalid form submission #2159
Browse files Browse the repository at this point in the history
  • Loading branch information
zahardev committed Dec 6, 2024
1 parent 12cd64a commit f44d730
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions assets/js/admin-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
$open_dialog.dialog( 'option', 'width', window_width );
});


// Make sure the user intends to leave the page before leaving.
window.addEventListener('beforeunload', ( event) => {
if ( vcfg.hasUnsavedChanges ) {
Expand Down Expand Up @@ -395,10 +394,14 @@
}

var error = viewConfiguration.validateValue( $field.val(), rules );

error ? viewConfiguration.disable_publish() : viewConfiguration.enable_publish();

$field.toggleClass( 'gv-error', !! error );

$field.parent().find( '.gv-error-message' ).remove();
if ( error ) {
$( '<div>' ).addClass( 'gv-error-message' ).text( error ).insertAfter( $field );
$( '<div>', { class: 'gv-error-message', text: error } ).insertAfter( $field );
}
},

Expand Down
Loading

0 comments on commit f44d730

Please sign in to comment.