New in version 6.3.0: See the new features.

Validate field

field_is_not_valid()

Checks the current value in the specified field against its validation list


SYNTAX

field_is_not_valid(field_id)

Validates the specified field_id taking into account its type & size, logical type, format and validation attributes.

The function returns FALSE (0) when the field value is valid or a non-zero value when the field value is not valid.


EXAMPLE

Here we show a generic function that checks the validation of all the textboxes in a textbox group:

-window winNames at 270,230 {
    max_width = 276
    max_height = 228
    event = winNamesEvent
    parent = wintask
    style = WS_INVISIBLE | WS_CLOSEBUTTON | WS_CAPTION | WS_OWNED
    data_font = "MS Sans Serif@10"
    label_font = "MS Sans Serif@10"
    title = "EDIT NAME"

    textbox group tg1 {

        +textbox tbFirstName at 90,30 {
            field = NAMES.FirstName
        }

        +textbox tbLastName at 90,60 {
            field = NAMES.LastName
        }

        +textbox tbAge at 90,100 {
            field = NAMES.Age
        }
    }
    . ...
}

. ...

!function IsValid_NAMES() {
!temp pcontrol,,p
!temp pfield,,p

    pcontrol = &first_control(winNames.tg1)

    while not (isnull(pcontrol)) {

        if (typeof(pcontrol) == OT_TEXTBOX) {

            pfield = &pcontrol->field

            if (field_is_not_valid(pfield)) {
                error pfield->heading + " does not have a valid value", \
                        "Valid values: " + pfield->valid
                return FALSE
            }
        }
        pcontrol = &next_object(pcontrol)
    }

    return TRUE
}

RELATED TOPICS

Data validation

Fields - validation