Retrieving
Form Data and Removing Leading and Trailing Whitespaces

The
form data entered by the user is stored in five WML variables:
username, password,
email, name
and birthday. Before validation can be done, we
have to retrieve the value of these WML variables. Any leading and
trailing whitespaces should be removed since we do not want the user
name, the password, etc, to be a few space characters:

Checking Whether
All Required Fields Has been Filled

Then
we use the following WMLScript code to check whether the user has
filled in all the required fields. The WMLScript code is very
straightforward. If any of the variables contains an empty string, we
will assign an error message to the WML variable errorMsg,
refresh the WML browser and quit the validate()
function:

if
(""==form_username){ WMLBrowser.setVar("errorMsg",
"The User Name field must not be
empty."); WMLBrowser.refresh(); return; }

if
(""==form_password){ WMLBrowser.setVar("errorMsg",
"The Password field must not be
empty."); WMLBrowser.refresh(); return; }

if
(""==form_email){ WMLBrowser.setVar("errorMsg",
"The Email field must not be
empty."); WMLBrowser.refresh(); return; }

The
following screenshots show the error message that you will see if you
do not fill in the username field:

Sony
Ericsson T68i

Nokia
Mobile Browser 4.0

Checking the Length
of Password

Next,
the length() function of the
String standard library is used to check the number of characters
contained in the password
variable. If it is fewer than eight, the WML browser will display an
error message to notify the user of the problem:

if
(String.length(form_password) <
8){ WMLBrowser.setVar("errorMsg", "The password
must contain at least 8 characters since a short password is less
secure."); WMLBrowser.refresh(); return; }

The
following screenshots show the error message that you will see if you
enter a password that contains fewer than eight characters:

What do you think about this web page? It is very helpful. It is helpful, but some information I wanted is missing. It is not helpful. It has broken links. It has typos / grammatical mistakes. It has incorrect information. Others

(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:

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