验证策略? [英] validation strategy?
本文介绍了验证策略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要确保三个电话号码字段中至少有一个具有值
(requiredfield)但是我不确定如何在没有服务器的情况下实现这一点
边逻辑。有没有办法使用验证控件来做到这一点?
谢谢。
I need to insure that at least one of three phone number fields has a value
(requiredfield) but I''m not sure of a way to implement this without server
side logic. Is there a way to use the validation controls to do this?
Thanks.
推荐答案
我是不确定是否有办法使用验证控件
而不是使用CustomValidator控件。 CustomValidator控件
确实要求你编写服务器端验证代码,但如果你编写了一个
客户端JavaScript函数,你可以设置
ClientValidationFunction属性允许启用JavaScript的浏览器
执行验证客户端。我自己从未使用过这个属性,
但听起来不应该太难。祝你好运!
-
Nathan Sokalski
nj ********@hotmail.com
http:/ /www.nathansokalski.com/
" Dabbler" <沓***** @ discussions.microsoft.com>在消息中写道
新闻:C5 ********************************** @ microsof t.com ...
I am not sure if there is a way to do that using the validation controls
other than using the CustomValidator Control. The CustomValidator Control
does require you to write server-side validation code, but if you write a
client-side JavaScript function as well you can set the
ClientValidationFunction property to allow JavaScript enabled browsers to
perform the validation client-side. I have never used this property myself,
but it doesn''t sound like it should be too hard. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
"Dabbler" <Da*****@discussions.microsoft.com> wrote in message
news:C5**********************************@microsof t.com...
我需要确保三个电话号码字段中至少有一个具有值
(requiredfield)但我不确定是否可以实现此方法没有服务器的边逻辑。有没有办法使用验证控件来做到这一点?
谢谢。
I need to insure that at least one of three phone number fields has a value
(requiredfield) but I''m not sure of a way to implement this without server
side logic. Is there a way to use the validation controls to do this?
Thanks.
< table>
< tr>
< td>
< asp:DropDownList ID =" ddlPhoneType" runat =" server">
< asp:ListItem Value =" Phone"> Phone< / asp:ListItem>
< asp:ListItem Value =" Mobile"> Mobile< / asp:ListItem>
< asp:ListItem Value =" Fax"> Fax< / asp:ListItem>
< / asp:DropDownList>
< / td>
< td>
< asp:TextBox ID =" txtMandatoryPhone" ;
runat =" server">< / asp:TextBox>< font color =" red"> *< / font>
< ; asp:RequiredFieldValidator ID =" valMandatoryPhone"
runat =" Server" ControlToValidate =" txtMandatoryPhone"
ErrorMessage ="您必须输入至少一个联系人
信息">< / asp:RequiredFieldValidator>
< / td>
< / tr>
< tr>
< td>
< asp:DropDownList ID =" DropDownList1" runat =" server">
< asp:ListItem>< / asp:ListItem>
< asp:ListItem Value =" Phone">电话< / asp:ListItem>
< asp:ListItem Value =" Mobile"> Mobile< / asp:ListItem>
< asp:ListItem Value = 传真>传真< / asp:ListItem>
< / asp:DropDownList>
< / td>
< ; td>
< asp:TextBox ID =" TextBox1" runat =" server">< / asp:TextBox>
< / td>
< / tr>
< ; tr>
< td>
< asp:DropDownList ID =" DropDownList2" runat =" server">
< asp:ListItem>< / asp:ListItem>
< asp:ListItem Value =" Phone">电话< / asp:ListItem>
< asp:ListItem Value =" Mobile"> Mobile< / asp:ListItem>
< asp:ListItem Value = 传真>传真< / asp:ListItem>
< / asp:DropDownList>
< / td>
< ; td>
< asp:TextBox ID =" TextBox2" runat =" server">< / asp:TextBox>
< / td>
< / tr>
< ; / table>
-
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
" Dabbler"写道:
<table>
<tr>
<td>
<asp:DropDownList ID="ddlPhoneType" runat="server">
<asp:ListItem Value="Phone">Phone</asp:ListItem>
<asp:ListItem Value="Mobile">Mobile</asp:ListItem>
<asp:ListItem Value="Fax">Fax</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtMandatoryPhone"
runat="server"></asp:TextBox><font color="red">*</font>
<asp:RequiredFieldValidator ID="valMandatoryPhone"
runat="Server" ControlToValidate="txtMandatoryPhone"
ErrorMessage="You must enter at least one contact
information"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="Phone">Phone</asp:ListItem>
<asp:ListItem Value="Mobile">Mobile</asp:ListItem>
<asp:ListItem Value="Fax">Fax</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="Phone">Phone</asp:ListItem>
<asp:ListItem Value="Mobile">Mobile</asp:ListItem>
<asp:ListItem Value="Fax">Fax</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
</table>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
我需要确保三个电话号码字段中至少有一个具有值
(requiredfield)但我不确定如何实现这一点没有服务器的边逻辑。有没有办法使用验证控件来执行此操作?
谢谢。
I need to insure that at least one of three phone number fields has a value
(requiredfield) but I''m not sure of a way to implement this without server
side logic. Is there a way to use the validation controls to do this?
Thanks.
聪明的解决方法Phillip!
但是我正在寻找一种方法来确保三个
文本框中至少有一个文本框中有一个值而没有指定为强制字段,如
这些在表单的不同部分 - 例如工作领域与家庭领域。
我现在有服务器端验证工作,但由于它没有使用
验证控制错误消息没有'一旦用户选择
离开现场,就会消失。
我想我将不得不刷新我的javascript!
感谢您的建议。
" Phillip Williams"写道:
Clever workaround Phillip!
but I''m looking for a way to just insure that at least one of three
textboxes has a value in it without designating on as the mandatory field, as
these are in different sections of the form - e.g. work fields vs home fields.
I have a server side validation working now, but since it doesn''t use
validation controls the error message doesn''t disappear once the user tabs
out of the field.
I guess I''m going to have to brush up on my javascript!
Thanks for your suggestion.
"Phillip Williams" wrote:
< table>
< tr>
< td>
< asp:DropDownList ID =" ddlPhoneType" runat =" server">
< asp:ListItem Value =" Phone"> Phone< / asp:ListItem>
< asp:ListItem Value =" Mobile"> Mobile< ; / asp:ListItem>
< asp:ListItem Value =" Fax"> Fax< / asp:ListItem>
< / asp:DropDownList>
< / td>
< td>
< asp:TextBox ID =" txtMandatoryPhone"
runat =" server">< / asp:TextBox>< font color =" red" ;> *< / font>
< asp:RequiredFieldValidator ID =" valMandatoryPhone"
runat =" Server" ControlToValidate =" txtMandatoryPhone"
ErrorMessage ="您必须输入至少一个联系信息>< / asp:RequiredFieldValidator>
< / td>
< ; / tr>
< tr>
< td>
< asp:DropDownList ID =" DropDownList1" runat =" server">
< asp:ListItem>< / asp:ListItem>
< asp:ListItem Value =" Phone"> Phone< / asp:ListItem>
< asp:ListItem Value =" Mobile"> Mobile< / asp:ListItem>
< asp:ListItem Value =" Fax"> Fax< / asp:ListItem>
< / asp:DropDownList>
< / td>
< td>
< asp:TextBox ID =" TextBox1" runat =" server">< / asp:TextBox>
< / td>
< / tr>
< tr>
< td>
< asp:DropDownList ID =" DropDownList2" runat =" server">
< asp:ListItem>< / asp:ListItem>
< asp:ListItem Value =" Phone"> Phone< / asp:ListItem>
< asp:ListItem Value =" Mobile"> Mobile< / asp:ListItem>
< asp:ListItem Value =" Fax"> Fax< / asp:ListItem>
< / asp:DropDownList>
< / td>
< td>
< asp:TextBox ID =" TextBox2" runat =" server">< / asp:TextBox>
< / td>
< / tr>
< / table>
-
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
Dabbler写道:
<table>
<tr>
<td>
<asp:DropDownList ID="ddlPhoneType" runat="server">
<asp:ListItem Value="Phone">Phone</asp:ListItem>
<asp:ListItem Value="Mobile">Mobile</asp:ListItem>
<asp:ListItem Value="Fax">Fax</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtMandatoryPhone"
runat="server"></asp:TextBox><font color="red">*</font>
<asp:RequiredFieldValidator ID="valMandatoryPhone"
runat="Server" ControlToValidate="txtMandatoryPhone"
ErrorMessage="You must enter at least one contact
information"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="Phone">Phone</asp:ListItem>
<asp:ListItem Value="Mobile">Mobile</asp:ListItem>
<asp:ListItem Value="Fax">Fax</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="Phone">Phone</asp:ListItem>
<asp:ListItem Value="Mobile">Mobile</asp:ListItem>
<asp:ListItem Value="Fax">Fax</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
</table>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dabbler" wrote:
我需要确保三个电话号码字段中至少有一个具有值
(requiredfield)但我不确定如何实现这一点没有服务器的边逻辑。有没有办法使用验证控件来做到这一点?
谢谢。
I need to insure that at least one of three phone number fields has a value
(requiredfield) but I''m not sure of a way to implement this without server
side logic. Is there a way to use the validation controls to do this?
Thanks.
这篇关于验证策略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文