代码如下:
<sharepoint:InputFormTextBox ID="UsernameTextBox" TextMode="MultiLine" runat="server" class="ms-input" RichTextMode="FullHtml" RichText="true"
Title="Username" Rows="6" Width="300px" Height="100px"/>
<sharepoint:InputFormCustomValidator ID="UsernameCustomValidator" runat="server" Display="Dynamic" SetFocusOnError="true"
ControlToValidate="UsernameTextBox"
ClientValidationFunction="IsValidUsername"
ErrorMessage="Your content must be at less 20 characters long (client-side validation)."
ValidateEmptyText="true" />
<script language="javascript">
function IsValidUsername(source, args)
{
if (args.Value.length >= 20)
args.IsValid = false;
else
args.IsValid = true;
}
</script>
在我没有设置RichText的时候, 可以验证, 但是设置RichText=True之后就无法验证了,是个怎么回事? 另外这控件生成的HTML源码是<textarea> 我用js直接获取<textarea>的value属性来控制长度也触发不了事件,该怎么解决?