Recent articles by this author

a name"aboutparams" span translate'0' Although typed parameters are not used in spanspan translate'0'JavaScriptspanspan translate'0'™spanspan translate'0', they are included in the method descriptions to indicate the types that are expected by each method. You declare ...

span translate'0' In this section, you add the spanspan translate'0'JavaScriptspanspan translate'0'™spanspan translate'0' code that interacts with the form. In the final step, you add a heading, a button, and an empty paragraph in the HTML body.span span translate'0' To ...

a name"wp1006156" Once you have defined the script parameters, you can insert your XFDL form. a name"wp1007511" To insert the form: a name"wp1007512" Place a comment wrapper between the script tags. For example: {code:670} SCRIPT ...script attributes... SCRIPT a ...

Description

This method returns the boolean result of whether a string is valid according to the setting of the node's format option.

Method

boolean isValidFormat (

String string

);

Parameters

Table 1. Method parameters

Expression

Type

Description

string

String

A string to be checked against the format. For example, to check 23.2 against a specific format, the string would be “23.2”.

Returns

The method returns true if the string matches the format, but false if the string does not match the format. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.

Example

The sample code checks to see if the strings '42' and '20071001' are valid for PAGE1.FIELD1. The results are displayed in a JavaScript™ alert message.

function testIsValidFormat(theForm) {

var s;

var node;

s = "--- Results of isValidFormat test ---\n";

node = theForm.dereferenceEx(null, "PAGE1.FIELD1", 0,

FormNodeP.UFL_ITEM_REFERENCE, null);

if(node == null) {

s += "Could not find FIELD1 on the form.\n";

} else {

s += " The value '42' is ";

if(node.isValidFormat("42") == false) s += "not ";

s += "a valid format for FIELD1.\n";

s += " The value '20071001' is ";

if(node.isValidFormat("20071001") == false) s += "not ";

s += "a valid format for FIELD1.\n";

}

alert(s);

}

If PAGE1.FIELD1 has a date format, the message displayed in the alert box should be: