Hello readers,
If you are using wordpress website and spamming occurs too much and in spam mails their are URLs then you should have to validate that message box and prevent user or spammer to add any type of URL in message box i.e. textarea or any input. Add below code in your “functions.php” of activated theme
add_filter( 'wpcf7_validate_textarea', 'alphanumeric_validation_filter', 2000, 2 );
function alphanumeric_validation_filter( $result, $your_message )
{
$your_message = new WPCF7_Shortcode( $your_message );
if ( 'your-message' == $your_message->your-message )
{
$name_of_the_input = isset( $_POST['your-message'] ) ? trim( $_POST['your-message'] ) : '';
if ( !preg_match('/^[a-zA-Z. ?0-9-,]+$/',$name_of_the_input) )
{
$result->invalidate( $your_message, "Allowed characters only" );
}
}
return $result;
}









![SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes](https://blog.rahulbhutani.com/wp-content/uploads/2020/04/123-218x150.jpg)







![SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes](https://blog.rahulbhutani.com/wp-content/uploads/2020/04/123-100x70.jpg)
