Jump to content

Onfocus on a contact form


AndrewC14

Recommended Posts

Hi guys I'll repeat as always...I'm a noob at both PHP and Javascript!

 

I'm having trouble with my errors on my contact form - When a user clicks on the box I would like the text "Please enter your name" to disappear (Which I've done successfully using onfocus) But if they don't click on that box and hit send again the text "Please enter your name does not disappear".

 

It's just to bulletproof my form really and make it more user friendly.

 

Here's my code for it:

 

if(isset($_POST['submit1'])) {

if(isset($_POST['cf_name']))

 

$names = check_input($_POST['cf_name']);

 

if($names=="")

$errorthing="Please enter your name";

 

Then on form (onfocus):

 

onfocus="if (this.value=='<?php echo $errorthing;?>') this.value=''; if (this.value=='<?php echo $names;?>')this.value='<?php $names ?>';"

 

Here's my web link too: http://xzen.co.uk/services/conceptual-model/

 

Thanks in advance, I really appreciate all the help! :)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.