Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter navyspitfire

    (@navyspitfire)

    Didn’t see that it was there since it’s white.

    Ben

    (@creatureweb)

    function sf_constantcontact_form($id,$p) {
    	return '<form id="'.$id.'_form" onsubmit="return '.$id.'_submit(this);" class="constantcontactwidget_form">'
    		.(empty($p['txt'])?'':('<p>'.$p['txt'].'</p>'))
    		.'<input type="hidden" name="grp" value="'.esc_attr($p['grp']).'" />'
    		.(empty($p['nam'])
    			?('<input type="text" name="eml" class="input" placeholder="'.__('Email').'"/>')
    			:('<p><label for="fnm">'.__('').'</label> <input type="text" name="fnm" placeholder="First Name" value="" class="input"/></p>'
    			.'<p><label for="lnm">'.__('').'</label> <input type="text" name="lnm" placeholder="Last Name" value="" class="input"/></p>'
    			.'<p><label for="eml">'.__('').'</label> <input type="text" name="eml" placeholder="E-mail" value="" class="input"/></p>'))
    		.(empty($p['req'])?'':('<p><input type="checkbox" name="req" class="input"> '.$p['req'].'</p>'))
    		.'<input type="submit" value="'.esc_attr($p['btn']).'" />'
    		.'</form>'
    		.'<script>function '.$id.'_submit(n){'
    			.'for(var a=n.querySelectorAll("input"),i=0,eml=false,val=["action=constantcontactadd"];i<a.length;i++)if(a[i].name){'
    				.'if(a[i].name=="req"){if(!a[i].checked){alert("'.__('Consent required').'");return false;}}'
    				.'else{if(!(a[i].name!="eml"||!a[i].value))eml=true;val.push(a[i].name+"="+encodeURIComponent(a[i].value));}'
    			.'}'
    			.'if(!eml){alert("'.__('Please enter an email address').'");return false;}'
    			.'var xml=new XMLHttpRequest();'
    			.'xml.open("POST","'.admin_url('admin-ajax.php').'",true);'
    			.'xml.setRequestHeader("Content-type","application/x-www-form-urlencoded");'
    			.'xml.onreadystatechange=function(){if(this.readyState==4){if(this.status==200){if(this.responseText)alert(this.responseText);else '.(preg_match('/^\/\/|^http:\/\/|^https:\/\//i',$p['msg'])?('setTimeout(\'window.location="'.esc_attr($p['msg']).'";\',100);'):('n.innerHTML="'.addslashes($p['msg']).'";')).'}else alert(this.statusText);}};'
    			.'xml.send(val.join(String.fromCharCode(38)));'
    			.'return false;'
    		.'}</script>';
    }
    Ben

    (@creatureweb)

    sorry I meant to be more specific. You’ll find the above code on line 94 of constantcontactwidget.php.

    You’ll see how I chose to add placeholders to each field. (might not be the best method as far as DOM is concerned and there may be browsers out there that are behind on supporting it but it works fine for me.)

    you could do this with jquery and be reasonably safe on updates:

    $ccwidget = $( '.widget_sf_widget_constantcontact' );
    $ccwidget.find('label' ).css('display', 'none');
    $ccwidget.find('input[name="fnm"]' ).attr('placeholder', 'First Name');
    $ccwidget.find('input[name="lnm"]' ).attr('placeholder', 'Last Name');
    $ccwidget.find('input[name="eml"]' ).attr('placeholder', 'Email');
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Placeholder text’ is closed to new replies.