---
name: "form_fieldtype"
section: "3x"
platform: "linux"
package: "ncurses"
version: "6.6-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/form_fieldtype/3x"
---

# form\_fieldtype(3x)

define validation-field types

## NAME

**form\_fieldtype** - define validation-field types

## SYNOPSIS

```
#include <form.h>
```

**FIELDTYPE \*new\_fieldtype(**\
     **bool (\* const** *field\_check***)(FIELD \*, const void \*),**\
     **bool (\* const** *char\_check***)(int, const void \*));** **int free\_fieldtype(FIELDTYPE \****fieldtype***);**

**int set\_fieldtype\_arg(**\
     **FIELDTYPE \****fieldtype***,**\
     **void \*(\* const** *make\_arg***)(va\_list \*),**\
     **void \*(\* const** *copy\_arg***)(const void \*),**\
     **void  (\* const** *free\_arg***)(void \*));** **int set\_fieldtype\_choice(**\
     **FIELDTYPE \****fieldtype***,**\
     **bool (\* const** *next\_choice***)(FIELD \*, const void \*),**\
     **bool (\* const** *prev\_choice***)(FIELD \*, const void \*));**

**FIELDTYPE \*link\_fieldtype(FIELDTYPE \****type1***,**\
                           **FIELDTYPE \****type2***);**

## DESCRIPTION

### new\_fieldtype

The function **new\_fieldtype** creates a new field type usable for data validation. Its parameters are function pointers:

- *field\_check*

  This function checks the validity of an entered data string whenever the user attempts to leave a field. It has two arguments:

  - •

    The (FIELD \*) argument is passed in so the validation predicate can see the field's buffer, sizes and other attributes.

  - •

    The second argument is an argument-block structure, about which more below.

- *char\_check*

  This function validates input characters as they are entered. The form library passes it the character to be checked and a pointer to an argument-block structure.

### free\_fieldtype

The **free\_fieldtype** function frees the space allocated for a given validation type by **new\_fieldtype**.

### set\_fieldtype\_arg

The function **set\_fieldtype\_arg** associates three storage-management functions with a field type:

- *make\_arg*

  This function is automatically applied to the list of arguments you give **set\_field\_type** when attaching validation to a field. It stores the arguments in an allocated argument-block object which is used when validating input.

- *copy\_arg*

  This function may be used by applications to copy argument-blocks.

- *free\_arg*

  Frees an argument-block structure.

You must supply the *make\_arg* function. The other two are optional: you may supply *NULL* for them. In this case, the form library assumes that *make\_arg* does not allocate memory but simply loads the argument into a single scalar value.

### set\_fieldtype\_choice

The form driver requests **REQ\_NEXT\_CHOICE** and **REQ\_PREV\_CHOICE** assume that the possible values of a field form an ordered set, and provide the forms user with a way to move through the set.

The **set\_fieldtype\_choice** function allows forms programmers to define successor and predecessor functions for the field type. These functions take the field pointer and an argument-block structure as arguments.

### link\_fieldtype

The function **link\_fieldtype** creates a new field type from the two given types. They are connected by a logical “or”.

## RETURN VALUE

The pointer-valued routines return NULL on error. They set **errno** according to their success:

- **E\_OK**

  The routine succeeded.

- **E\_BAD\_ARGUMENT**

  Routine detected an incorrect or out-of-range argument.

- **E\_SYSTEM\_ERROR**

  System error occurred, e.g., malloc failure.

The integer-valued routines return one of the following codes on error:

- **E\_OK**

  The routine succeeded.

- **E\_BAD\_ARGUMENT**

  Routine detected an incorrect or out-of-range argument.

- **E\_CONNECTED**

  The field is already connected to a form.

- **E\_CURRENT**

  The field is the current field.

- **E\_SYSTEM\_ERROR**

  System error occurred (see [**errno**(3)](/errno/3.md)).

## PORTABILITY

These routines emulate the System V forms library. They were not supported on Version 7 or BSD versions.

## AUTHORS

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond.

## SEE ALSO

**curses**(3X), **form**(3X), **form\_field\_validation**(3X)
