Home Forums WoodMart support forum Inline Validation on checkout form

Inline Validation on checkout form

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #542552

    ijaskaur92
    Participant

    How I can apply Inline validations on checkout page?
    I need to delete last name, I want only first name.

    #542877

    Hello,

    You can configure the checkout fields in Dashboard -> WooCommerce -> Checkout Fields.
    https://xtemos.com/docs-topic/fields-manager/

    Best Regards.

    #542979

    ijaskaur92
    Participant

    How about inline validation, I want not to display validation all together at the top but want to display validation messages on each field.

    #543179

    Hello,

    Please add the below code to the functions.php file into the Child theme.

    add_filter( 'woocommerce_form_field', 'pk_checkout_fields_in_label_error', 10, 4 );
    
    function pk_checkout_fields_in_label_error( $field, $key, $args, $value ) {
    	if ( strpos( $field, '</label>' ) !== false && $args['required'] ) {
    		$error = '<span class="error" style="display:none">';
    		$error .= sprintf( __( '%s is a required field.', 'woocommerce' ), $args['label'] );
    		$error .= '</span>';
    		$field = substr_replace( $field, $error, strpos( $field, '</label>' ), 0);
    	}
    	return $field;
    }

    Then, add the following Custom CSS code to Theme Settings > Custom CSS > Global Custom CSS:

    .woocommerce-checkout p.woocommerce-invalid-required-field span.error {
       color: #e2401c;
       display: block !important;
       font-weight: bold;
    }

    Best Regards.

    #543285

    ijaskaur92
    Participant

    Thank you for sharing code. Required field are working fine. But it still showing in blocks as well, How to remove this?
    For postal code invalid, this message is not showing inline, but showing in block. Please advise.
    I just want to show only below 2 messages in blocks as per attached screenshot.

    Attachments:
    You must be logged in to view attached files.
    #543516

    Hello,

    Sorry to say there are no options in theme settings to achieve this. Such modification requires complicated code customization which is not covered by our support.

    You need to find a third party plugin to achieve more functionality that best suits you.
    https://wordpress.org/plugins/linear-checkout-for-woo-by-cartimize/

    Best Regards.

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)