Chapter 9. Introduction to WMLScript

Now that you have reached this point in the book, you should have a good idea of the things that can be done with WML alone: static page layouts and simple user interaction. Until now, the only way you could have any complicated interactions would be with some sort of dynamic content on the server.

Although WML provides variables, tasks, and events to make interaction much cleaner and easier, there are some tasks that can’t be done in WML alone. If data must be checked for validity, for instance to make sure that a phone number really looks like a phone number or to check that a credit card number has the right number of digits, this checking has to be done by something outside WML.

The most obvious way to do this checking would be the way it was done on the Web for a long time: send the data to the server and let the server do the checking. This approach has one big problem, however: the time taken for the round trip to the server and back. Just think of the web sites where you enter your address, click OK, and wait the best part of a minute before they tell you that you haven’t included a phone number.

A better approach is to do the checking on the browser, before sending anything to the server. This is exactly why WMLScript was designed.

WMLScript with WML

One of the most important things about WMLScript is how tightly it integrates with WML. You can put a call to WMLScript anywhere you can put a WML task. In the other direction, scripts can read ...

Get Learning WML, and WMLScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.