Created
June 9, 2016 14:12
-
-
Save salcode/5158b37208887f69e558db46182a84a3 to your computer and use it in GitHub Desktop.
jQuery JavaScript to populate a blank comment with an Automated Comment. This is being done on the client side because on the server side there is no filter available before the check for an empty comment body.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery('#commentform').on('submit', function() { | |
var $comment = jQuery('#comment'); | |
if ( '' === $comment.val().trim() ) { | |
$comment | |
.css({'color':'#fff'}) | |
.val( 'Automated Comment: ' + Math.floor( new Date().getTime() / 1000 ) ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment