条件自定义验证客户端 [英] conditional Custom validation client side

查看:74
本文介绍了条件自定义验证客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




是否存在条件客户端验证,例如ex。



已完成部分

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





我的问题是我要验证用户没有选择空白项目。



喜欢





2010

2011

2012

2013​​



编辑:



忘记了条件部分

数据源来自List,在List的最后一个条目我添加了Others,这意味着数据库中不存在年份,用户可以添加他不想的年份。如果用户选择其他将显示另一年的文本框,然后我想检查是否知道是否有条件,如果用户只选择现有年份o其他。



PS:抱歉我的英语不好

解决方案

试试:



http://asp.net-tutorials.com/validation/required-field-validator/ [ ^ ]



希望它有所帮助



Azee ...


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


访问这里......



ASP.NET MVC3中的自定义客户端验证 [ ^ ] < br $> b $ b





http://msdn.microsoft.com/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:

http://asp.net-tutorials.com/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

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.clientvalidationfunction.aspx[^]


这篇关于条件自定义验证客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆