The Validate event has different arguments for different objects:
Object |
See |
---|---|
For use with PSWebDataWindowClass objects, see Validate in the chapter on server-side Web DataWindow events.
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.
None
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.
Use to set a condition for the page or a control on the page.
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;
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.
PSPasswordClass, PSTextAreaClass, PSTextClass
Argument |
Description |
---|---|
sNewValue |
String variable for the new value the user enters |
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.
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.
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);