当前位置: 首页 > news >正文

网站是做百度快照推广好博客网站

网站是做百度快照推广好,博客网站,wordpress 单页分类,中国早期互联网公司Validator是Atlas提供的一组验证用户输入的客户端组件,用来检查InputControl类型的Atlas控件,例如Web.UI.TextBox的输入数据。在ASP.NET中提供了一组服务器端的验证控件,Atlas中的Validator在客户端也提供了同样的功能。 主要内容 1&#xff…

Validator是Atlas提供的一组验证用户输入的客户端组件,用来检查InputControl类型的Atlas控件,例如Web.UI.TextBox的输入数据。在ASP.NET中提供了一组服务器端的验证控件,Atlas中的Validator在客户端也提供了同样的功能。

 主要内容

  1.Validators概述

  2.完整示例

  一.Validators概述

  Validator是Atlas提供的一组验证用户输入的客户端组件,用来检查InputControl类型的Atlas控件,例如Web.UI.TextBox的输入数据。在ASP.NET中提供了一组服务器端的验证控件,Atlas中的Validator在客户端也提供了同样的功能。Atlas提供的Validator如下所示:

  1.requiredFieldValidator:检查是否有数据输入。

  2.typeValidator:检查输入的数据是否为特定的类型。

  3.rangeValidator:检查输入的值是否在一个范围之内。

  4.customValidator:用自定义的验证函数验证输入。

  5.regexValidator:用指定的正则表达式验证输入。

  某个Atlas客户端控件的Validator可被定义成一个集合,当控件的propertyChanged事件被引发时,Atlas将调用Validator集合中的所有Validator去验证输入的数据。在验证的过程中一旦失败,这个Validator的validationMessage将被设置。Validator可以以组的形式验证一组控件的输入,并统一显示错误信息。您还可以指定一个validationErrorLabel控件关联于某个将被验证的输入控件,它可以显示验证过程中的错误并可以自定义错误提示。[来自于Dflying的介绍]

  二.完整示例

  下面针对这几种Validator做几个简单的小例子。

  1.requiredFieldValidator

  检测是否有有数据输入,用一个textbox接收用户输入,用一个label来显示错误信息:

<div>
  <h3>Example 1: Required Field Validator</h3>
  <br />
  <input type="text" id="value1TextBox" class="input" />
  &nbsp; <span id="validator1" style="color: red">You must enter some text</span>
  <br />
  <br />
  Text: <span id="value1Label" class="result"></span>
  <br />
</div>

 编写Atlas脚本,分别用一个requiredFieldValidator和validtionErrorLabel,并且把用户输入的数据显示在一个label上,在validationErrorLabel中用associatedControl来关联要验证的控件:

<script type="text/xml-script">
  <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
    <components>
     <textBox id="value1TextBox">

        <validators>

          <requiredFieldValidator errorMessage="You must enter some text."/>
        </validators>
     </textBox>
     <validationErrorLabel id="validator1" associatedControl="value1TextBox" />
     <label id="value1Label">
      <bindings>
        <binding dataContext="value1TextBox" dataPath="text" property="text" />
      </bindings>
     </label>
    </components>
  </page>
</script>

  2.typeValidator

  检测用户输入的数据类型,在这个例子中我们验证用户输入的是否为数据:

<div>
<h3>Example 2: Type Validator</h3>
  <br />
  <input type="text" id="value2TextBox" class="input" />
  <br />
  <br />
  <span id="validator2" style="color:red">You must enter a valid number</span>
</div>

  编写Atlas脚本,设置非常简单,指定type为Number:

<script type="text/xml-script">
  <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
    <components>
    <textBox id="value2TextBox">
            <validators>
              <requiredFieldValidator errorMessage="You must enter a number." />
              <typeValidator type="Number" errorMessage="You must enter a valid number" />
            </validators>
          </textBox>
          <validationErrorLabel id="validator2" visibilityMode="Hide" associatedControl="value2TextBox" />
    </components>
  </page>
</script>

 3.regexValidator

  用正则表达式来验证用户输入的数据,这里我们以验证用户录入的电话号码格式是否正确为例,添加相关的HTML元素:

<div>
  <h3>Example 3: RegEx Validator</h3>
  <input type="text" id="value3TextBox" class="input" />
  <br />
  <br />
  <span id="validator3" style="color: red">You must a valid phone number</span>
</div>

  编写Atlas脚本,加入regexValidator,注意这儿在正则表达式的前后必须加入“/”?否则会报脚本错误:

<script type="text/xml-script">
  <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
    <components>
    <textBox id="value3TextBox">
      <validators>
        <requiredFieldValidator errorMessage="You must enter some text." />
        <regexValidator regex="/((d{3,4})|d{3,4}-)?d{7,8}/" errorMessage="You must a valid phone number" />
      </validators>
    </textBox>
      <validationErrorLabel id="validator3" visibilityMode="Collapse"
      associatedControl="value3TextBox" />
    </components>
  </page>
</script>

 



http://www.hkea.cn/news/166254/

相关文章:

  • 一个com的网站多少钱管理微信软件
  • 蒙阴网站建设软文代写网
  • 用python做一旅游网站南昌seo计费管理
  • 湖北省建设厅win10优化软件哪个好
  • 湖南企业建站系统平台软文有哪些发布平台
  • 南通 网络 公司网站真正免费建站
  • 做图骂人的图片网站网络服务
  • wordpress主标题副标题seo基础
  • 淮安做网站优化百度竞价排名是什么方式
  • 食品公司网站源码谷歌网页
  • 做网站用哪种代码比较好推广seo发贴软件
  • 3d效果图软件宁波seo行者seo09
  • 美国做按摩广告的网站网站优化教程
  • wordpress云建站教程信息流广告公司一级代理
  • 我有一个域名怎么做网站百度一下下载
  • 郑州网站建设品牌好安装百度到桌面
  • 株洲做网站定制百度灰色词优化排名
  • 上海网页设计公司兴田德润电话排名优化外包公司
  • 做360网站优化快推广普通话宣传语手抄报
  • 动态网站开发语言有哪些大学生创新创业大赛
  • 关键词推广公司网站网络排名优化方法
  • 福州移动网站建设网络营销推广工具有哪些
  • win2008sr怎么用iis做网站国外网站加速
  • 合肥++网站建设磐石网站seo
  • 万网主机怎么上传网站如何在百度上投放广告
  • 做网站时如何给文字做超链接全球疫情最新数据消息
  • 四川省住建厅官方网站3分钟搞定网站seo优化外链建设
  • 做网站阳泉巨量千川广告投放平台
  • 温岭哪里有做网站的如何自制网站
  • 知道创于 wordpress搜索引擎优化宝典