综合练习:
<validators>
<field name="username">
<field-validator type="requiredstring">
<message>用户名不能为空!</message>
</field-validator>
</field>
<!-- 校验密码 -->
<field name="password">
<field-validator type="requiredstring">
<message>密码不能为空!</message>
</field-validator>
<field-validator type="stringlength">
<param name="minLength">6</param>
<param name="maxLength">12</param>
<message>密码需要在6-12位之间</message>
</field-validator>
</field>
<!-- 校验确认密码 -->
<field name="repassword">
<field-validator type="fieldexpression">
<param name="expression"><![CDATA[(password==repassword)]]></param>
<message>两次密码输入不一致!</message>
</field-validator>
</field>
<!-- 校验年龄 -->
<field name="age">
<field-validator type="int">
<param name="min">18</param>
<param name="max">60</param>
<message>年龄必须在18-60之间</message>
</field-validator>
</field>
<!-- 生日 -->
<field name="birthday">
<field-validator type="date">
<param name="min">1954-01-01</param>
<param name="max">1996-12-31</param>
<message>生日需要在54-96年之间的</message>
</field-validator>
</field>
<!-- 校验邮箱 -->
<field name="email">
<field-validator type="email">
<message>邮箱格式不正确</message>
</field-validator>
</field>
<!-- 电话 -->
<field name="phone">
<field-validator type="regex">
<param name="expression"><![CDATA[^18\d{9}$]]></param>
<message>手机号格式不正确!</message>
</field-validator>
</field>
</validators>