开发者

ASP.net, Ajax, JavaScript help

I need help in how to set webform control proprietie开发者_Python百科s 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>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜