close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Storing error messages in the form fields

Thread began 3/24/2010 11:53 am by gwh362692 | Last modified 3/31/2010 7:33 pm by gwh362692 | 1357 views | 10 replies

gwh362692

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.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...