Highlight required fields in PHPRunner and ASPRunner.NET

PHPRunner and ASPRunner.NET can validate required fields automatically. You can also make empty required fields more noticeable by highlighting them while the user is filling out the form.

In this example, an empty required field is highlighted in yellow. As soon as the user enters a value, the normal background is restored.

1. Make the field required

Open the field's Edit as settings and enable the Required field option.

Set a field as required in PHPRunner and ASPRunner.NET

The Required field option handles validation when the form is submitted. The JavaScript below adds a visual indication while the user is filling out the form.

2. Add JavaScript to the page

Open the JavaScript OnLoad event for the Add or Edit page and add the following code:

Replace CompanyName with the name of your required field.

The function runs when the page loads and again whenever the field value changes. An empty field is highlighted immediately, and the highlight disappears when the user enters a value.

3. Build and test the application

Build your project and open the Add or Edit page in the browser. Empty required fields will be highlighted until the user enters a value.

Required field highlighted in the generated application

Highlight several required fields

To apply the same behavior to several fields, list their field names in an array:

Replace the example field names with the required fields from your own table.

Using a different highlight style

You can change the background color or add other CSS styles if you want required fields to stand out differently. For example:

Applies to

  • PHPRunner
  • ASPRunner.NET