条件自定义验证客户端

编程入门 行业动态 更新时间:2024-10-28 01:21:28
本文介绍了条件自定义验证客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨 是否存在条件客户端验证,例如ex。 已完成部分

我有一个包含年份的绑定下拉列表,在页面加载期间查询年份并选择用户已保存的年份,请说2011。

我的问题是我要验证用户没有选择空白项目。 喜欢 2010 2011 2012 2013​​ 编辑: 忘记了条件部分 数据源来自List,在List的最后一个条目我添加了Others,这意味着数据库中不存在年份,用户可以添加他不想的年份。如果用户选择其他将显示另一年的文本框,然后我想检查是否知道是否有条件,如果用户只选择现有年份o其他。 PS:抱歉我的英语不好

解决方案

试试: asp-tutorials/validation/required-field-validator/ [ ^ ] 希望它有所帮助 Azee ...

RequiredFieldValidator实际上非常简单,但非常有用。您可以使用它来确保用户在TextBox控件中输入了一些内容。让我们试一试,并在我们的页面中添加一个RequiredFieldValidator。我们还将添加一个TextBox进行验证,以及一个用于提交表单的按钮。 < 表格 id = form1 runat = server > 您的姓名:< br / > < asp:TextBox runat = server id = txtName / > < asp:RequiredFieldValidator runat = server id = reqName controltovalidate = txtName errormessage = 请输入您的姓名! / > < br / > < br / > < asp:按钮 runat = server id = btnSubmitForm text = Ok / > < / form > 实际上,这就是全部我们需要测试RequiredFieldValidator的最基本部分。我确信控件的所有属性现在都有意义,因此我不会详细介绍它们。尝试运行网站并单击按钮。你应该看到这样的东西:

访问这里...... ASP.NET MVC3中的自定义客户端验证 [ ^ ] b $ b 或 msdn.microsoft/en-us/library/system.web.ui.webcontrols.customvalidator.clientvalidationfunction.aspx [ ^ ]

Hi Does a Conditional Client side validation exist like for ex. done part

I have a bind dropdownlist which contains years, during the page load it queries the year and select the year which the user have saved lets say "2011".

My problem is I want to validate that the user didn't choose a blank item. like "" "2010" "2011" "2012" "2013" EDIT: forgot the Conditional part The Datasource comes from a List and at the last entry of the List I've added "Others" which means that the year didn't exist on the database, user can add the year that he wan't. If the user select Others a textbox for the other year will be visible and then I want to check if know if there is a condition if user only select existing year o Other. PS: sorry for my bad English

解决方案

Try: asp-tutorials/validation/required-field-validator/[^] Hope it helps Azee...

The RequiredFieldValidator is actually very simple, and yet very useful. You can use it to make sure that the user has entered something in a TextBox control. Let's give it a try, and add a RequiredFieldValidator to our page. We will also add a TextBox to validate, as well as a button to submit the form with. <form id="form1" runat="server"> Your name:<br /> <asp:TextBox runat="server" id="txtName" /> <asp:RequiredFieldValidator runat="server" id="reqName" controltovalidate="txtName" errormessage="Please enter your name!" /> <br /><br /> <asp:Button runat="server" id="btnSubmitForm" text="Ok" /> </form> Actually, that's all we need to test the most basic part of the RequiredFieldValidator. I'm sure that all the attributes of the controls makes sense by now, so I won't go into details about them. Try running the website and click the button. You should see something like this:

visit here... Custom Client Side Validation in ASP.NET MVC3[^] or msdn.microsoft/en-us/library/system.web.ui.webcontrols.customvalidator.clientvalidationfunction.aspx[^]

更多推荐

条件自定义验证客户端

本文发布于:2023-08-07 15:03:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319762.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   客户端   条件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!