Validate

The Validate event has different arguments for different objects:

Object

See

psPage

Syntax 1 For psPage objects

PSPasswordClass, PSTextAreaClass, PSTextClass

Syntax 2 For server-side text controls

For use with PSWebDataWindowClass objects, see Validate in the chapter on server-side Web DataWindow events.


Syntax 1 For psPage objects

Description

Occurs after all data binding has taken place and all validation has been performed. It allows you to do page-level validation in 4GL JSP targets.

Arguments

None

Returns

Boolean. If true is returned, the page is considered valid. If false is returned, the psPage.ValidationError event is triggered. The action that fails validation is not performed. You must include a return value in the event script.

Usage

Use to set a condition for the page or a control on the page.

Examples

Example 1

This example tests for whether a user-entered password is valid (the same value as the user name). If it is not, the ValidationError event is triggered. If it is valid, the AfterBinding event is triggered and (usually) a Redirect method is called:

return userid.value == password.value;

See also

ValidationError


Syntax 2 For server-side text controls

Description

Occurs when the client changes the value of a text control in 4GL JSP targets. The value entered by the user is passed to the event.

Applies to

PSPasswordClass, PSTextAreaClass, PSTextClass

Arguments

Argument

Description

sNewValue

String variable for the new value the user enters

Returns

Boolean. If true is returned, the validation is considered successful. If false is returned, the control.ValidationError event is triggered. The action that fails validation is not performed. You get a compiler error if you do not include a return value in the event script.

Usage

If this event is not scripted, validation is assumed to have succeeded.

This event gives you a chance to do complex validation on the value (for example, by calling an EAServer component to do the validation). Simple validation should preferably be written in client-side JavaScript.

Examples

Example 2

This example calls the validate method on an EAServer component called “n_creditcard”. The method (and event) returns true if the credit card is valid.

return
		n_creditcard.validate(amount,
			cc_type,cc_number,cc_expiration);

See also

ValidationError