weixin_33688840 2010-02-08 07:41 采纳率: 0%
浏览 30

ASP.net,Ajax,JavaScript帮助

I need help in how to set webform control proprieties in asp.net and ajax control using javascript.

I have asp page that has checkBox, TextBox, MaskedEditExtender, and RegularExpressionValidator.

I set the mask for MaskedEditExtender as Mask="(999)999-9999" and I set the ValidationExpression for RegularExpressionValidator as ValidationExpression="\d{10}".

I want to change these two properties when user checked the international checkbox to: Mask="999999999999" and as ValidationExpression="\d{12}" Using JavaScript without interrupting with server side and when the user unchecked they get previous value so the interaction should be only in the client side.

Please help me with this and here is my code:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">

      function pageLoad() {
      }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:CheckBox ID="chkIntphoneHome" runat="server"  Text="Internation Code" 
                AutoPostBack="false"/>

            <asp:TextBox ID="txtHomePhone" runat="server"></asp:TextBox>


        <cc1:MaskedEditExtender ID="txtHomePhone_MaskedEditExtender" runat="server" 
            AutoComplete="False" CultureAMPMPlaceholder="" 
            CultureCurrencySymbolPlaceholder="" CultureDateFormat="" 
            CultureDatePlaceholder="" CultureDecimalPlaceholder="" 
            CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True" 
            Mask="(999)999-9999" TargetControlID="txtHomePhone">
        </cc1:MaskedEditExtender>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ErrorMessage="RegularExpressionValidator" ControlToValidate="txtHomePhone" 
            ValidationExpression="\d{10}"></asp:RegularExpressionValidator>        

    </div>
    </form>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • helloxielan 2010-02-08 07:51
    关注

    Instead of meddling with the maskEditor/validator controls' client-side behaviour, are you OK with having 2 sets of textbox+maskExtender+validator?

    Set 1 = texbox_HomePhone + maskEditExtender_HomePhone + regexValidator_HomePhone
    Set 2 = texbox_IntHomePhone + maskEditExtender_IntHomePhone + regexValidator_IntHomePhone

    Using the checkbox to toggle (via javascript) the display/hidding of either set.

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?