ClientValidationFunction Property

  Microsoft Speech Technologies Homepage

Gets or sets the name of a client-side function that checks the value of the target of the SemanticItemToValidate property. Read/write.

Usage

ASP.NET markup: <speech:CustomValidator ClientValidationFunction="..." />
Get value: String = CustomValidator.ClientValidationFunction;
Set value: CustomValidator.ClientValidationFunction = String;
Data type: String
Required: Yes

Remarks

The control throws the ArgumentNullException if ClientValidationFunction is not specified.

Syntax

bool FunctionName ( string value )
{
     // Client-side code referenced by CustomValidator.ClientValidationFunction
}

Parameters

  • value
    The contents of SemanticItemToValidate.

Return Value

True if the value is valid; False if the value is invalid.

Example

In this example, the user's date of birth is collected by a Application Speech Control. The ClientValidationFunction routine tests that the date spoken by the user is in the past.

<form id="Form1" method="post" runat="server">
  ...
  <asp:panel id="AppPanel" runat="server" borderstyle="None">
    <Speech:SemanticMap id="TheSemanticMap" runat="server">
      <Speech:SemanticItem id="siDay" runat="server"></Speech:SemanticItem>
      <Speech:SemanticItem id="siMonth" runat="server"></Speech:SemanticItem>
      <Speech:SemanticItem id="siYear" runat="server"></Speech:SemanticItem>
    </Speech:SemanticMap>
    ...
    <Speech:CustomValidator id="CV1" ClientValidationFunction="checkDate" 
      SemanticItemToValidate="siYear" runat="server">
      <Prompt PromptSelectFunction="SayInvalidDatePromptFunction"></Prompt>
    </Speech:CustomValidator>
  
    <Speech1:Date id="PastDate" runat="server" DateContext="Past" RejectThreshold="0.25" 
      DaySemanticItem="siDay" MonthSemanticItem="siMonth" YearSemanticItem="siYear" 
      MaxTimeout="30000" InitialTimeout="3000" FirstInitialTimeout="1000" AutoPostBack="True" 
      BabbleTimeout="10000" QuestionPrompt="What is your date of birth?" AllowRelativeDates="False" 
      AllowHolidays="False">
    </Speech1:Date>
    ...
  </asp:panel>
  ...
</form>

<script>
  function checkDate()
  {
    var dob = new Date(siYear.value, siMonth.value-1, siDay.value);
    var today = new Date();
    return (dob.getTime() < today.getTime());
  }
</script>

See Also

CustomValidator Class | CustomValidator Constructor | CustomValidator Members | CustomValidator Properties | CustomValidator Methods | CustomValidator Events | CustomValidator Remarks