Support General disable user from submitting mobile and email in text area using frontend form Reply To: disable user from submitting mobile and email in text area using frontend form

#13793
Anh TranAnh Tran
Keymaster

Hi,

I think this can be done with custom JavaScript only. So you need to enqueue your JS file on the page that has the form, then in the code, when the form is being submitted, check if the value of the textarea is a mobile number or email address. If it is, then return false to prevent the submission.

This is a pseudo-code that might give you some idea:

jQuery( function( $ ) {
    $( '.your-form' ).on( 'submit', function() {
        var value = $( '#your-field' ).val();
        if ( checkIfIsMobileNumberOrEmail( value ) ) {
            return false;
        }
    } );
} );