• Resolved donmcleman

    (@donmcleman)


    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?

    https://www.ads-software.com/plugins/simple-subscribe/

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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,
    Mart

    Thread Starter donmcleman

    (@donmcleman)

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Setting and clearing default value in input box’ is closed to new replies.