Page 1 of 1

Re: Limit menu input to a single digit?

Posted: Fri Mar 23, 2012 2:11 pm
by support
Yes, you must specify in your grammar that you expect a one digit input. There are many ways to do this, but here an example:

Code: Select all

<form id="my_form">
  <field name="my_field" type="digits?length=1">
    <prompt>
      Your prompt here.
    </prompt>

    <filled>
      One digit was entered.
    </filled>

  </field>
</form>
You can find more info about grammars here: http://www.plumvoice.com/docs/dev/voicexml:tags:grammar

Re: Limit menu input to a single digit?

Posted: Mon Mar 26, 2012 11:31 am
by support
In your code example, you are loading two grammars. The 'type="digits?length=1"' is a built-in grammar (see: http://www.plumvoice.com/docs/dev/devel ... n_grammars), and then you declared your own JSGF grammar below that. You should only do one or the other as now your application is checking the user's input against two different grammars, which may be causing the small delay.

Also take care to declare the grammar rules within parenthesis, like this:

Code: Select all

<field name="confirm">
    <grammar type="application/x-jsgf" mode="dtmf">(1|2|3)</grammar>

    <prompt>
      You entered <value expr="morningReading"/>. If that's correct, press 1, otherwise press 2.
    </prompt>