WML Input Fields

Preferences - Do not show ads

Input fields are used to obtain alphanumeric data from users. The <input/> tag is used to create input fields. Let's first take a look at the following WML example. Then we will mention about some of the commonly used attributes of the <input> element.


<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd">

  <card id="card1" title="WML Input Fields">
      Hello, welcome to our WML tutorial.<br/>
      What's your name?
      <input name="myname" maxlength="16"/>

Like a selection list, an input field is associated with a variable, which stores the data entered by the user. The variable name is specified with the name attribute of the <input> element. In the above WML example, a variable myname is associated with the input field. If you enter Tom in the input field, the variable myname will contain the value Tom. Further details about variables will be discussed in the section "WML Variables" of this tutorial.

The maxlength attribute of the <input> element limits the number of characters that a user can enter in an input field. In the above WML example, a user can enter at most 16 characters in the input field.

The following screenshots show the result of the above WML example in some mobile phone browsers:

Sony Ericsson T610

Sony Ericsson T68i

Nokia Mobile Browser 4.0

In the above WML example, we have not set a default value to the input field. So, as you can see in the screenshots, the input field is empty at the beginning. If you want to set a default value to the input field, you need to specify the value attribute in the <input> element. For example, if we change the following line:

<input name="myname" maxlength="16"/>


<input name="name" maxlength="16" value="Jack"/>

Then the input field will contain the word "Jack" by default.

Page 35 of 50 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top

Feedback Form (Expand)

What do you think about this web page?

WML Tutorial Table of Contents WML Tutorial Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page