AndrewC14 Posted April 29, 2012 Share Posted April 29, 2012 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! Quote Link to comment Share on other sites More sharing options...
AndrewC14 Posted April 29, 2012 Author Share Posted April 29, 2012 Anybody Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 30, 2012 Share Posted April 30, 2012 You haven't explained what you want. If you want text to disappear regardless of what action the user takes, don't display it in the first place. Quote Link to comment Share on other sites More sharing options...
AndrewC14 Posted April 30, 2012 Author Share Posted April 30, 2012 But I need to display it to give them an error for not filling it in. They then receive the error and they click on the box - the text then disappears so they can write their details in Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 30, 2012 Share Posted April 30, 2012 If I understand you, the function to check if it's filled in needs to be called when the form is submitted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.