Simple Subscribe
[resolved] Setting and clearing default value in input box (3 posts)

  1. donmcleman
    Posted 1 year ago #

    Hi, thanks for a great plugin, I like what it does.

    I've been racking my brains over this problem. In Forms.php I've added a line under $form to display a default value in my input box:

    ->setDefaultValue('E-mail address...')

    When a user clicks in the input box I would like the default text to disappear (it's what the user expects). I understand this is easily achieved with Javascript, but where do I put that javascript?

    Or was Forms.php the wrong place to set a default value?


  2. latorante
    Posted 1 year ago #

    Hi there mate,

    you have more than one way to achieve that.

    Javascript way:

    ->setAttribute('onfocus', "if (this.value == 'E-mail address') {this.value = '';}")
    ->setAttribute('onblur', "if (this.value == '') {this.value = 'E-mail address';}")

    HTML5 way:

    ->setAttribute('placeholder', "E-mail address")

    Kind regards,

  3. donmcleman
    Posted 1 year ago #

    Wow, that was quick! Thank you for being on the ball!

    I actually came back here straightaway to add that I've just seen that you've already answered that question for someone else in the thread 'How do I change the value of the email text input with onblur/onfocus'. I've changed the code and it works, I am so pleased.

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic