# profile-builder/3.16.1/assets/js/placeholder-labels.js

User Profile Builder – Beautiful User Registration Forms, User Profiles &amp; User Role Editor, version 3.16.1. 42 lines.

- Page: https://pluginprobe.com/plugins/profile-builder/3.16.1/code/assets/js/placeholder-labels.js
- Raw: https://pluginprobe.com/plugins/profile-builder/3.16.1/raw/assets/js/placeholder-labels.js
- Modified: 2024-09-02T10:26:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/profile-builder/3.16.1/code/assets/js/placeholder-labels.js#L10-L20`.

```javascript
/*
 * Function that adds placeholders to Login Forms and Widget fields
 *
 * @since v.2.1
 *
 */
jQuery( document ).ready( function() {

    // add placeholder to Login Form Fields
    loginFieldPlaceholder();

    // add placeholder to the 2FA Field
    loginAuthPlaceholder();

});

/**
 * Add Placeholder for Login Form Fields
 *
 */
function loginFieldPlaceholder () {
    jQuery(".login-username input, .login-password input").each( function ( index, elem ) {
        var element_id = jQuery( elem ).attr( 'id' );
        if( element_id && ( label = jQuery( elem ).parents( '#wppb-login-wrap' ).find( 'label[for=' + element_id + ']' ) ).length === 1 ) {
            jQuery( elem ).attr( 'placeholder', jQuery( label ).text() );
        }
    });
}

/**
 * Add Placeholder for 2FA Field on Login Form
 *
 */
function loginAuthPlaceholder () {
    let element = jQuery( ".login-auth input" ),
        element_id = element.attr( 'id' ),
        label =  jQuery( 'label[for=' + element_id + ']' );

    if( element_id && label.length === 1 ) {
        jQuery( '#' + element_id ).attr( 'placeholder', label.text() );
    }
}
```
