Page 1 of 1

what if a field allows multiple lengths of digits?

Posted: Wed Sep 08, 2004 1:12 pm
by czhang
I'm working on a field that allows 9 digits or 11 digits,
Below is the code I tried but didn't work.

<field name="sth" type="digits">
<grammar type="application/x-regexp">{9}|{11}</grammar>

Thanks.

link to builtin IVR grammars

Posted: Fri Sep 10, 2004 11:42 am
by support
The easiest way to do this is to add parameters to your builtin IVR grammar.

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">

<form>
  <field name="sth" type="digits?minlength=9;maxlength=11">
    <prompt>Please enter some digits</prompt>
    <filled>
      You entered <value expr="sth"/>
    </filled>
  </field>
</form>
When you specify the field "type" attribute you are loading the builtin IVR grammar "digits". More info on builtin IVR grammars can be found here:

http://www.w3.org/TR/voicexml20/#dmlABuiltins

Hope this helps :)

The Plum Support Team

Posted: Fri Sep 10, 2004 1:36 pm
by czhang
but my problem is that the number has to be 9 digits OR 11 digits long, not from 9 digits TO 11 digits.
I'm now handling it using <if> and it works find, I just wonder if there's a more effecient way to use grammar to handle it. Thanks

IVR built-in grammar lengths

Posted: Fri Sep 10, 2004 2:07 pm
by support
In the case of 9 digits or 11 digits you can simply reference the builtin IVR grammars with lengths individually:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">

<form>
  <field name="sth">
    <prompt>Please enter some digits</prompt>
    <grammar src="builtin:dtmf/digits?length=9"/>
    <grammar src="builtin:dtmf/digits?length=11"/>
    <filled>
      You entered <value expr="sth"/>
    </filled>
  </field>
</form>

</vxml>
This IVR code resticts the input to either 9 or 11 digits.

Hope This Helps!

The Plum Support Team