zoukankan      html  css  js  c++  java
  • 13 RangeValidator

    • RangeValidator的属性有:

             MinimumValue:范围的最小值; MaximumValue:范围的最大值。Type:为数据类型,包括String,Intege   ,Double ,Date , Currency

    • RangeValidator,CompareValidator,RegularExpressValidator都不会对非空值进行校验,所以如果字段不允许为空则需要再使用RequiredFieldValidator控件。

    实例:

         输入一个日期,此日期的范围在1900年到当前的日期为止并且不能为空,因为我们在表单上放上一个textBox,给它关联一个RangeValidator和RequriedFiledValidator两个验证控件。设置RangeValidator的MinimumValue为1900-01-01,动态设置MaxiMumValue为当前的日期,并设置它的type为date类型。如果为空时需显示RequiredFiledValidator,则把范围验证控件的display设置为Dynamic.

        再放入一个textBox,用于输入一个年龄,范围为0-100,也不能为空,同上设置:

    在表单加载后中写入cs代码:

    protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                    RangeValidator1.MaximumValue = DateTime.Now.ToShortDateString();
            }
  • 相关阅读:
    oracle列合并
    Java移位操作符
    angularjs 事件向上向下传播
    angularjs 路由 ngRoute tab切换
    angularjs 自定义服务
    angularjs 服务供应商
    angularjs 缓存 $q
    angularjs $location 服务
    angularjs $http 服务
    angularjs 自定义指令 directive
  • 原文地址:https://www.cnblogs.com/yagzh2000/p/3130480.html
Copyright © 2011-2022 走看看