disable user from submitting mobile and email in text area using frontend form

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13781
    baraanajjar@gmail.com[email protected]
    Participant

    Hi There i am looking for a solution if some body type mobile number or email address to submit form
    so that the form must not submit how to disable user if he type mobile or email in text area. before form submit using frontend form submit plugin

    #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;
            }
        } );
    } );
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.