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 | ![]() |
- 1. WML (Wireless Markup Language) Introduction
- 2. WML Deck and Card
- 3. WML Document Structure
- 4. WML Generic Metadata: <meta>
- 5. Comments in WML
- 6. Line Breaking in WML
- 7. Font Size and Style in WML
- 8. WML Preformatted Text: <pre>
- 9. WML Images
- 10. WML Tables
- 11. WML Anchor Links
- 12. Programming Softkeys of Mobile Phones and the <do> Element
- 13. WML Template and Menu
- 14. WML Events and the <onevent> Tag
- 15. Timer and the ontimer Event
- 16. WML Event: onenterbackward
- 17. WML Event: onenterforward
- 18. WML Selection Lists and the onpick Event
- 19. WML Input Fields
- 20. WML Variables
- 21. Submitting Form Data to the Server in WML
- 22. Clearing a Saved Form in WML