0

I am editing the form for a WordPress login and want to remove text from a field when clicked on.

I found a solution, but cannot get it working correctly... here is the code:

<input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="Username" size="20" onfocus="' . if(this.value  == 'Username') { this.value = ''; } . '" onblur="' . if(this.value == '') { this.value = 'Username'; } . '" />

I added the onfocus and onblur, but it throws back an error:

Parse error: syntax error, unexpected 'if' (T_IF)

I have obviously done it incorrect, but not sure on the correct way of doing so. Any help would be appreciated.

Thanks

user3642210
  • 111
  • 1
  • 1
  • 12
  • You can't use JavaScript within PHP... You can use PHP within PHP though... You need to wrap your statements in `` or `= ?>` for shorthand. – aug Jul 09 '16 at 19:26
  • I thought as much... issue is it's within a general-template file for WordPress, so with limited knowledge would probably be a nightmare to do it that way. Thank you though @aug – user3642210 Jul 09 '16 at 19:29

0 Answers0