Storing error messages in the form fields
Hi everyone,
I have the following basic form on my page.
<div id="newsletter">
<form action="" method="post" id="newsletter" name="newsletter">
<fieldset>
<p>Sign up to our newsletter.</p>
<div>
<label for="firstname">First Name:</label>
<input id="firstname" name="firstname" type="text" value="First name" onfocus="if (this.value == 'First name') this.value=''" onblur="if (this.value == '') this.value='First name'" /> </div>
<div>
<label for="lastname">Last Name:</label>
<input id="lastname" name="lastname" type="text" value="Last name" onfocus="if (this.value == 'Last name') this.value=''" onblur="if (this.value == '') this.value='Last name'" /> </div>
<div>
<label for="email">Email:</label>
<input id="email" name="email" type="text" value="Email address" onfocus="if (this.value == 'Email address') this.value=''" onblur="if (this.value == '') this.value='Email address'" />
</div>
<div id="submit_button">
<input type="submit" class="submit" value="Subscribe" name="submit" />
</div>
</fieldset>
</form>
</div>
I just applied the server validation that comes with CSS form builder but I wanted the error messages to be displayed within the form fields, ie. instead of:
value="First name"
it would be:
value="First name is required."
I wondered if someone could tell me how I'd go about doing this?
I've also applied an insert record server behaviour to the form and have the "after insert go to" field set to:
index.php?sent=true
In the above form I have the following line:
<p>Sign up to our newsletter.</p>
But after the record is inserted I wanted the contents of the above p tags to be replaced with a confirmation message.
I have the following already:
<?php if(isset($_GET['sent']) && $_GET['sent'] == "true") { ?> <p id="confirm"> <strong>Thank you – your details have been processed. </strong></p><?php } ?>
But this would just show the confirmation text and not actually replace the contents of the previous p tags.
I wondered if I could get some advice on how to do this?
Appreciate any help.