Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Created March 8, 2016 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/30ccbd887f181306bc1b to your computer and use it in GitHub Desktop.
Save kellenmace/30ccbd887f181306bc1b to your computer and use it in GitHub Desktop.
( function ( $ ) {
$( document ).ready( function () {
//Require post title when adding/editing Project Summaries
$( 'body' ).on( 'submit.edit-post', '#post', function () {
// If the title isn't set
if ( $( "#title" ).val().replace( / /g, '' ).length === 0 ) {
// Show the alert
window.alert( 'A title is required.' );
// Hide the spinner
$( '#major-publishing-actions .spinner' ).hide();
// The buttons get "disabled" added to them on submit. Remove that class.
$( '#major-publishing-actions' ).find( ':button, :submit, a.submitdelete, #post-preview' ).removeClass( 'disabled' );
// Focus on the title field.
$( "#title" ).focus();
return false;
}
});
});
}( jQuery ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment