typeof operator
conditional operators
OPERATOR: isvalid
isvalid
The
isvalid
operator is used to test the validity of a variable or the result type of executing an expression. A boolean value is returned to denote the results of the test. A
true
is returned if the variable or result type is valid. A
false
is returned if the variable or result type is invalid.
Do not confuse this operator with the
URL.isValid
function which is used to validate the syntax of a URL address string.
The classic case of an invalid result type for an expression is dividing by zero. In this example, as expected, the
isvalid
operator returns a
false
.
Code for IsvalidExample.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1">
<p>
isvalid example
</p>
<do type="accept">
<go href="IsvalidExample.wmls#findisvalid()" />
</do>
</card>
<card id="card2">
<p>
isvalid = $(valid)
</p>
</card>
</wml>
Code for IsvalidExample.wmls
extern function findisvalid()
{
var zerodiv = 1/0;
var valid =
isvalid
(zerodiv);
WMLBrowser.setVar("valid", valid);
WMLBrowser.go("IsvalidExample.wml#card2");
};
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information