Title: replace_comment_field_callback autocomplete=&#8221;nope&#8221; breaks validation
Last modified: April 8, 2019

---

# replace_comment_field_callback autocomplete=”nope” breaks validation

 *  Resolved [Bjarne Oldrup](https://wordpress.org/support/users/oldrup/)
 * (@oldrup)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/replace_comment_field_callback-autocompletenope-breaks-validation/)
 * Thanks for a nice plugin, it seems to do its job.
 * I think I stumpled over a tiny bug… The post comment textarea html, sets the 
   autocomplete attribute to “nope”, while the only valid options are “on” and “
   off”. See snippet below:
 * <p class=”comment-form-comment”><label for=”comment” class=”screen-reader-text”
   >Kommentar</label><textarea autocomplete=”nope” id=”e5ee7999a9″ name=”e5ee7999a9″
   cols=”45″ rows=”8″ aria-required=”true”>
 * [https://www.w3schools.com/tags/att_input_autocomplete.asp](https://www.w3schools.com/tags/att_input_autocomplete.asp)
 * That breaks otherwise valid html output.
 * Easy to reproduce. Disable Antispam Bee and the site validates, enable and the
   error re-occurs.
 * The culprit seems to be this function
 *     ```
       	/**
       	 * The callback function for the preg_match_callback to modify the textarea tags.
       	 *
       	 * @since   2.6.10
       	 *
       	 * @param array $matches The regex matches.
       	 *
       	 * @return string The modified content string.
       	 */
       	public static function replace_comment_field_callback( $matches ) {
       		if ( self::get_option( 'time_check' ) ) {
       			$init_time_field = sprintf(
       				'<input type="hidden" name="ab_init_time" value="%d" />',
       				time()
       			);
       		} else {
       			$init_time_field = '';
       		}
   
       		$output = '<textarea autocomplete="nope" ' . $matches['before1'] . $matches['before2'] . $matches['before3'];
   
       		$id_script = '';
       		if ( ! empty( $matches['id1'] ) || ! empty( $matches['id2'] ) ) {
       			$output   .= 'id="' . self::get_secret_id_for_post( self::$_current_post_id ) . '" ';
       			$id_script = '<script type="text/javascript">document.getElementById("comment").setAttribute( "id", "a' . substr( esc_js( md5( time() ) ), 0, 31 ) . '" );document.getElementById("' . esc_js( self::get_secret_id_for_post( self::$_current_post_id ) ) . '").setAttribute( "id", "comment" );</script>';
       		}
   
       		$output .= ' name="' . esc_attr( self::get_secret_name_for_post( self::$_current_post_id ) ) . '" ';
       		$output .= $matches['between1'] . $matches['between2'] . $matches['between3'];
       		$output .= $matches['after'] . '>';
       		$output .= $matches['content'];
       		$output .= '</textarea><textarea id="comment" aria-hidden="true" name="comment" autocomplete="nope" style="padding:0;clip:rect(1px, 1px, 1px, 1px);position:absolute !important;white-space:nowrap;height:1px;width:1px;overflow:hidden;" tabindex="-1"></textarea>';
   
       		$output .= $id_script;
       		$output .= $init_time_field;
   
       		return $output;
       	}
       ```
   
 * After changing autocomplete=”nope” to autocomplete=”off” the site validates.
 * Best regards
    Bjarne Oldrup
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Freplace_comment_field_callback-autocompletenope-breaks-validation%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Contributor [Torsten Landsiedel](https://wordpress.org/support/users/zodiac1978/)
 * (@zodiac1978)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/replace_comment_field_callback-autocompletenope-breaks-validation/#post-11403486)
 * This is intended, because of the non-existing browser support.
 * Please see this issue for the details:
    [https://github.com/pluginkollektiv/antispam-bee/issues/142](https://github.com/pluginkollektiv/antispam-bee/issues/142)
 * Maybe this is not the case anymore and we could revisit this. If you have recent
   information about this matter, please open a Github issue and we look at this
   again.
 * Thank in advance!
 * All the best,
    Torsten
 *  Thread Starter [Bjarne Oldrup](https://wordpress.org/support/users/oldrup/)
 * (@oldrup)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/replace_comment_field_callback-autocompletenope-breaks-validation/#post-11405036)
 * Oh! Thank you for the quick response. I’ve done som digging, and opened a Github
   issue.
 * [https://github.com/pluginkollektiv/antispam-bee/issues/280](https://github.com/pluginkollektiv/antispam-bee/issues/280)
 * Best regards
    Bjarne

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘replace_comment_field_callback autocomplete=”nope” breaks validation’
is closed to new replies.

 * ![](https://ps.w.org/antispam-bee/assets/icon-256x256.png?rev=2898402)
 * [Antispam Bee](https://wordpress.org/plugins/antispam-bee/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/antispam-bee/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/antispam-bee/)
 * [Active Topics](https://wordpress.org/support/plugin/antispam-bee/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/antispam-bee/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/antispam-bee/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Bjarne Oldrup](https://wordpress.org/support/users/oldrup/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/replace_comment_field_callback-autocompletenope-breaks-validation/#post-11405036)
 * Status: resolved