100分求解:ASP.NET和数据校验
如下一段代码是浏览器上看到的:
<TR>
<TD class="firstcol">证件类型</TD>
<TD>
<SPAN id="UC_CustomerData1_fld_pid_type"><INPUT id="UC_CustomerData1_fld_pid_type_0" type="radio" name="UC_CustomerData1:fld_pid_type"
value="I" /><LABEL for="UC_CustomerData1_fld_pid_type_0">公民身份证</LABEL><INPUT id="UC_CustomerData1_fld_pid_type_1" type="radio" name="UC_CustomerData1:fld_pid_type"
value="T" /><LABEL for="UC_CustomerData1_fld_pid_type_1">临时身份证</LABEL><INPUT id="UC_CustomerData1_fld_pid_type_2" type="radio" name="UC_CustomerData1:fld_pid_type"
value="S" /><LABEL for="UC_CustomerData1_fld_pid_type_2">军官证</LABEL><INPUT id="UC_CustomerData1_fld_pid_type_3" type="radio" name="UC_CustomerData1:fld_pid_type"
value="P" /><LABEL for="UC_CustomerData1_fld_pid_type_3">中华人民共和国护照</LABEL><INPUT id="UC_CustomerData1_fld_pid_type_4" type="radio" name="UC_CustomerData1:fld_pid_type"
value="L" /><LABEL for="UC_CustomerData1_fld_pid_type_4">营业执照</LABEL><INPUT id="UC_CustomerData1_fld_pid_type_5" type="radio" name="UC_CustomerData1:fld_pid_type"
value="O" /><LABEL for="UC_CustomerData1_fld_pid_type_5">其他有效证件</LABEL></SPAN>
<SPAN id="UC_CustomerData1_RequiredFieldValidator10" controltovalidate="UC_CustomerData1_fld_pid_type"
errormessage="*" display="Dynamic" evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
initialvalue="" style="color:Red;display:none;">*</SPAN></TD>
</TR>
<TR>
<TD class="firstcol">证件号码</TD>
<TD>
<INPUT name="UC_CustomerData1:fld_pid_info" type="text" maxlength="20" size="20" id="UC_CustomerData1_fld_pid_info"
class="TextBox_Show" onfocus="this.className='TextBox_Over';" onblur="this.className='TextBox_OnBlur';"
onkeydown="if(event.keyCode == 13) event.keyCode = 9;" onclick="javascript:clear_check(UC_CustomerData1_rgv_pid_info, UC_CustomerData1_fld_pid_type);" />
<SPAN id="UC_CustomerData1_rgv_pid_info" controltovalidate="UC_CustomerData1_fld_pid_info"
errormessage="*" display="Dynamic" evaluationfunction="RegularExpressionValidatorEvaluateIsValid"
validationexpression="\d{18}|\d{15}" style="color:Red;display:none;">*</SPAN> <SPAN id="UC_CustomerData1_RequiredFieldValidator43" controltovalidate="UC_CustomerData1_fld_pid_info"
errormessage="*" display="Dynamic" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;display:none;">
*</SPAN></TD>
</TR>
对应的ASPX描述是这样的:
<TD class="firstcol">证件类型</TD>
<TD>
<ASP:RADIOBUTTONLIST id="fld_pid_type" runat="server" repeatdirection="Horizontal" repeatlayout="Flow"
enableviewstate="False">
<ASP:LISTITEM value="I">公民身份证</ASP:LISTITEM>
<ASP:LISTITEM value="T">临时身份证</ASP:LISTITEM>
<ASP:LISTITEM value="S">军官证</ASP:LISTITEM>
<ASP:LISTITEM value="P">中华人民共和国护照</ASP:LISTITEM>
<ASP:LISTITEM value="L">营业执照</ASP:LISTITEM>
<ASP:LISTITEM value="O">其他有效证件</ASP:LISTITEM>
</ASP:RADIOBUTTONLIST>
<ASP:REQUIREDFIELDVALIDATOR id="RequiredFieldValidator10" runat="server" controltovalidate="fld_pid_type" display="Dynamic"
errormessage="*" enableviewstate="False"></ASP:REQUIREDFIELDVALIDATOR></TD>
</TR>
<TR>
<TD class="firstcol">证件号码</TD>
<TD>
<ASP:TEXTBOX id="fld_pid_info" runat="server" enableviewstate="False" columns="20" maxlength="20"></ASP:TEXTBOX>
<ASP:REGULAREXPRESSIONVALIDATOR id="rgv_pid_info" runat="server" controltovalidate="fld_pid_info" display="Dynamic"
errormessage="*" validationexpression="\d{18}|\d{15}"></ASP:REGULAREXPRESSIONVALIDATOR>
<ASP:REQUIREDFIELDVALIDATOR id="RequiredFieldValidator43" runat="server" controltovalidate="fld_pid_info" display="Dynamic"
errormessage="*" enableviewstate="False"></ASP:REQUIREDFIELDVALIDATOR></TD>
</TR>
请教:我如何在客户端添加一些JavaScript代码,使得选中证件类型=身份证时,规则表达式校验器rgv_pid_info才起作用,而选中其他证件类型时,不需要校验是否输入了15、18个数字字符?