We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

what if a field allows multiple lengths of digits?

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
czhang
Posts: 13
Joined: Fri Aug 20, 2004 10:37 am

what if a field allows multiple lengths of digits?

Post 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.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

link to builtin IVR grammars

Post 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
Last edited by support on Thu Feb 25, 2010 4:18 pm, edited 2 times in total.

czhang
Posts: 13
Joined: Fri Aug 20, 2004 10:37 am

Post 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

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR built-in grammar lengths

Post 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

Post Reply