Home > Articles > Web Services > XML

  • Print
  • + Share This
Like this article? We recommend

Baseball Facts Hotline

Let’s jump into forms by building a login page for our Baseball Facts Hotline. Users will need to log in with their telephone number and a pin code. After validation, the server will deliver another VoiceXML form to determine their request parameters and then play back the result.

Listing 1 shows a first cut at our login form. From a data type perspective, we need to capture both a valid phone number and a four-digit pin number. Fortunately, the Voxeo voice server has built-in grammars for both phone and digits, so we can use the handy type attribute to specify our grammar as in the following:

<field name="userid" type="phone">
<field name="pin" type="digits?length=4">

In our example, the digits type has been augmented with one of the digit grammar options, digits?length=4, to make sure we capture exactly four digits from the user. Other options for digits enable us to fine-tune digit input with one of the options to specify a length, minimum length, and maximum length for a string of digits. For example, to specify a minimum length of n, use the following:

<field type="digits?minlength=n" />

To specify a maximum length of n, use the following:

<field type="digits?maxlength=n" />

And, to specify a minimum length of x and a maximum length of y, use the following:

<field type="digits?minlength=x;maxlength=y" />

In our example, we want to enforce the entry of exactly four digits, so we use the following:

<field name="pin" type="digits?length=4">
  • + Share This
  • 🔖 Save To Your Account