FORMfields, the premiere web framework
Support Home | Knowledge Base | Documentation | Forums | Contact Us
FORMfields & FORMgen :: Field Customizations

Clearing the Value of a Field When Clicked On or Tabbed To

(2321 views. Last Updated: 2007-08-09 1:12 PM)

In this example we will demonstrate how to clear the value of a field when the user 1st clicks the field or 1st tabs to the field. We will assume that you have already used FORMgen to specify a default value for this field.

1. We will assume that you want to apply this functionality to a PersonNameField named "first_name", however this step will work with any FORMfields field that is based on a single text box. For example: TextField, TextAreaField, StreetAddressField, etc..
$ffForm->addField(new PersonNameField("first_name", "First Name", FORM_FIELD_REQUIRED));
$ffForm->addField(new PersonNameField("first_name", "First Name", FORM_FIELD_REQUIRED));

2. Add JavaScript to your page's "head" tag:
<script type="text/javascript">
var firstNameCleared = false;
Support | Earn Money
Copyright © 2005-2020 Brain Book Software LLC.
Built with FORMfields, the premiere web framework.