WMLScript » String » String.isEmpty

Syntax:
String.isEmpty(string)
string
The mandatory string parameter can be any string containing zero or more of any combination of characters (including white spaces). This parameter can also be an empty string.

Determines if a string is empty.

The String.isEmpty function tests the length of a given string to determine if it is empty and returns a boolean value. If the string has zero length, true is returned. if the string has a length greater than zero, false is returned.

Note that you can use the String.length function to find the numeric length of a string.

Examples

Code:
<?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>
   isEmpty example
   </p>
   <do type="accept">
      <go href="IsEmptyExample.wmls#findisempty()" />
   </do>
</card>

<card id="card2">
<p>
   string = $(strng)
   <br />
   empty = $(result)
</p>
</card>

</wml>
Explanation:

Code for IsEmptyExample.wml

Language(s): WML
Code:
extern function findisempty()
{
   var str = Dialogs.prompt("Enter a string", "");
   var res = String.isEmpty(str);
   WMLBrowser.setVar("strng", str);
   WMLBrowser.setVar("result", res);
   WMLBrowser.go("IsEmptyExample.wml#card2");
};
Explanation:

Code for IsEmptyExample.wmls

Language(s): WML

See Also: