19.3. Controlling Whether Input Fields can be Left Empty (emptyok Attribute)

The emptyok attribute of the <input> element helps you control whether an input field can be empty. It either takes a true or false as the value. Here are two WML examples that demonstrate the usage of the emptyok attribute:

<input name="name" emptyok="false"/>

Meaning: A user must enter some text in the input field created by the above WML markup.

<input name="name" emptyok="true"/>

Meaning: An input field created by the above WML markup accepts empty input.

Note that if both the emptyok attribute and format attribute are specified to the same <input> element and conflict occurs between the two attribute values, the emptyok attribute takes precedence. For example, suppose we create an input field using the following WML markup:

<input name="name" format="N" emptyok="true"/>

The format attribute value and the emptyok attribute value in the above markup conflict with each other. "format="N"" specifies that a single numeric character must be entered, but "emptyok="true"" states that the input field can be empty. In this case, the emptyok attribute takes precedence. So, the input field can either be left empty or contain a single numeric character.

Here is another WML example:

<input name="name" format="*M" emptyok="false"/>

"format="*M"" states that the input field can contain any number of characters (i.e. having no character is valid). However, as "emptyok="false"" takes precedence, the input field must contain at least one character.

Previous Page Page 38 of 50 Next Page

Feedback Form (ExpandCollapse)

What do you think about this web page?

(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.

(Optional) Your name:

(Optional) Your email address:

Please enter again to confirm:

Due to the amount of messages we received, we may not be able to reply to all messages.