Determines if the syntax of the URL is correct.
The URL.isValid function returns a
boolean value that signifies whether the given absolute or relative URL
is of the correct syntax for a URL. A true is returned if the
syntax is correct. A false is returned if the syntax is not
correct.
The syntax of a URL is:
scheme://host:port/path;parameters$query#fragment
Note that this function does not provide a reason as to why a syntax is invalid. Further, simply because the syntax is of a valid form and a true is returned, does not guarantee that the URL address is correct and that the browser can successfully navigate to the site.
<?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>
valid = $(valid)
</p>
</card>
</wml>Code for IsValidExample.wml
extern function findisvalid()
{
var testurl = Dialogs.prompt("Enter the URL",
"");
var val = URL.isValid(testurl);
WMLBrowser.setVar("valid", val);
WMLBrowser.go("IsValidExample.wml#card2");
};
Code for IsValidExample.wmls