• Resolved aliorg7

    (@aliorg7)


    Hi there,
    How to limit the accepted number of characters in text or tel filed?(in my case 11 only)
    Also how to validate the field to accept only numbers and no other characters?
    I am using this from the elementor form API page. but my regex format is not right I guess.

    // Validate the Tel field is in XXXXXXXXXX 01234567899 format.
    add_action( ‘elementor_pro/forms/validation’, function ( $record, $ajax_handler ) {
    $fields = $record->get_field( [
    ‘id’ => ‘ir_tel_format’,
    ] );

    if ( empty( $fields ) ) {
    return;
    }

    $field = current( $fields );

    if ( 1 !== preg_match( ‘/[0-9]{11}/’, $field[‘value’] ) ) {
    $ajax_handler->add_error( $field[‘id’], ‘eroor message’ );
    }
    }, 10, 2 );

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Lisa R

    (@lisaelementor)

    Hi @aliorg7
    Since you are using Pro, you’ll need to open a support ticket at my.elementor.com. www.ads-software.com rules state that commercial products are not supported here.

    Hi Lisa,

    Can you please help? I am trying to edit my page in Elementor and I get this error below. I have tried the suggested recommendations of deactivating plugins. I also submitted a ticket via Elementor and no one has replied. I really need this resolved quickly. THANK YOU!

    Fatal error: Uncaught TypeError: Argument 1 passed to Elementor\Controls_Stack::sanitize_settings() must be of the type array, null given, called in /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php on line 1022 and defined in /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php:1933 Stack trace: #0 /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php(1022): Elementor\Controls_Stack->sanitize_settings(NULL) #1 /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php(1775): Elementor\Controls_Stack->get_data(‘settings’) #2 /home4/graziano/public_html/wp-content/plugins/elementor/core/base/base-object.php(132): Elementor\Controls_Stack->get_init_settings() #3 /home4/graziano/public_html/wp-content/plugins/elementor/core/base/base-object.php(40): Elementor\Core\Base\Base_Object->ensure_settings() #4 /home4/graziano/public_html/wp-content/plugins/ocean-elementor-widgets/modules/but in /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php on line 1933
    Uncaught TypeError: Argument 1 passed to Elementor\Controls_Stack::sanitize_settings() must be of the type array, null given, called in /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php on line 1022 and defined in /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php:1933
    Stack trace:
    #0 /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php(1022): Elementor\Controls_Stack->sanitize_settings(NULL)
    #1 /home4/graziano/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php(1775): Elementor\Controls_Stack->get_data(‘settings’)
    #2 /home4/graziano/public_html/wp-content/plugins/elementor/core/base/base-object.php(132): Elementor\Controls_Stack->get_init_settings()
    #3 /home4/graziano/public_html/wp-content/plugins/elementor/core/base/base-object.php(40): Elementor\Core\Base\Base_Object->ensure_settings()
    #4 /home4/graziano/public_html/wp-content/plugins/ocean-elementor-widgets/modules/but

    THANK YOU!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Validate elelmentor form field to accept only digits and no other character (in’ is closed to new replies.