2011-08-08 35 views
2

我無法找到任何有關如何使用Spring.net驗證輸入字段長度的好信息,但它必須是可能的。這裏是我曾經嘗試過的:如何使用Spring.net驗證輸入長度?

<v:condition test="string.Length(InputField) > 2000" > 
    <v:message id="Errors.TooLong2000" providers="InputField"/> 
</v:condition> 

但是,這個失敗了被Spring解析。任何幫助表示讚賞!

回答

0

假設你的價值屬性被稱爲Text

<v:condition test="InputField.Text.Length &lt;= 2000" when="InputField.Text != null"> 
    <v:message id="Errors.TooLong2000" providers="InputField"/> 
</v:condition> 
+1

謝謝!我的字段實際上被稱爲「InputField」,所以這是有效的規則: ' – TimH