Home / Forums / DynamiX Support / Watermark text in contact form fields

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts

  • Aaron
    Participant

    For the footer contact form, I want to take away the labels to the side and add watermark text in the field instead.  Can this be done using your form?  I looked at Contact Form 7 and it's a confuscated mess for something as simple as what I want to achieve.

    Andy
    Andy
    Keymaster

    Hi Aaron,

    You'll need to edit DynamiX/lib/inc/sub-functions.php – search for the following

    the name field


    <input type="text" name="<?php echo $id; ?>name" id="<?php echo $id; ?>name" value="" class="field" />

    the email field


    <input type="text" name="<?php echo $id; ?>emailFrom" id="<?php echo $id; ?>emailFrom" value="" class="field" />

    You'll notice the labels directly under both lines of code – remove the lable and add to the above fields the below (but change to what you require).


    onFocus="if(this.value == '<?php _e('Name', 'DynamiX' ); ?>') {this.value = '';}" onBlur="if (this.value == '') {this.value = '<?php _e('Name', 'DynamiX' ); ?>';}"

    e.g. 


    <input type="text" onFocus="if(this.value == '<?php _e('Name', 'DynamiX' ); ?>') {this.value = '';}" onBlur="if (this.value == '') {this.value = '<?php _e('Name', 'DynamiX' ); ?>';}" name="<?php echo $id; ?>name" id="<?php echo $id; ?>name" value="" class="field" />

    Aaron
    Participant

    Ok.  Almost spot on.  First off… Thanks!

    Second, the labels only show up after I click in the field and click out.  I need them to show before clicking in the field.  What code do I need to modify for that?

    Third, the "Name" field passes validation without entering a name in the field, although the email doesn't.  What code do I need to modify to ensure that doesn't happen? 

    The label I used for the name field is "your name" and for email "your email" (I'm very boring that way).

     


    Aaron
    Participant

    Got it.  Never mind.  I had the dumb.  Thanks so much for the help!


    Aaron
    Participant

    Only thing I need to do is modify the Javascript so that if the name field is left at default "Your Name" then it fails validation and seeks for input from the user.


    Aaron
    Participant

    Hah!  I got it!  Coolness.

    Andy
    Andy
    Keymaster

    Hi Aaron, 

    Sorry about the delay, are you all set on this now?

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

You must be logged in to reply to this topic.