0

I have this validation javascript in my master page to disable a button on two content pages:

      EnableSubmit = function (val) {          
            var sbmt = document.getElementById("btnRegister")          
            if (val.checked == true) 
                sbmt.disabled = false;
            }
            else {
                sbmt.disabled = true;
            }
        }

and this in my content page:

  <asp:Button ID="btnRegister" Enabled="true"  runat="server" Class="btn       btn-danger btn-lg btn-block"  Text="Register Your Domain" OnClick="btnRegister_Click" />

        <input type="checkbox" id="terms"  value="terms" onclick="EnableSubmit(this)"  checked>

It worked well without a master page, but not with. Any solutions? Please Advise, thanks!

wtwe
  • 51
  • 1
  • 5
  • 1
    What is a master page? That may make sense to you, but for the rest of us that only have the information you posted here, it means nothing. For the record, if you are trying to disable a button on a different page (meaning the user has to click, and a server request is sent and the page reloaded), then the state is lost between the HTTP requests unless you save the data in a cookie, local storage or on the server side. If my comment doesnt make sense, make an example page that illustrates your post and use jsfiddle, that way we can see your problem. – lrossy Oct 23 '15 at 20:34
  • 1
    Check the ID of your button. Are you using clientIDMode="static"? Your Submit button ID may be getting changed by .Net. – Gregg Duncan Oct 23 '15 at 20:50
  • Whar the hell is a master page? Reminds me of FrontPage bk in the 90s – An0nC0d3r Oct 23 '15 at 20:50
  • @Irossy - It does mean something to those of us familiar with asp.net which is one of the tags this question carries. If you don't understand the platform please don't comment. You only show your ignorance. – Gregg Duncan Oct 23 '15 at 20:52
  • 2
    A master page is an ASP.Net implementation. Since he has asp.net tagged, he shouldn't need to explain it since you can use teh Googles if you really want to know. – Tony Hinkle Oct 23 '15 at 20:53
  • By default ASP changes the IDs of elements when the page is rendered. So if you have any scripts that reference IDs, you can set clientIDMode="static" as @GreggDuncan stated. `` – Tony Hinkle Oct 23 '15 at 20:57
  • sorry I didn't add the correct number of spaces to get the button code to show up in the message text... button code is showing now. – wtwe Oct 23 '15 at 20:58
  • Possible duplicate of [How to stop ASP.NET from changing IDs in order to use jQuery](http://stackoverflow.com/questions/497802/how-to-stop-asp-net-from-changing-ids-in-order-to-use-jquery) – Tony Hinkle Oct 23 '15 at 20:59
  • @wtwe - Check the output to the browser by viewing the source code in the browser window. Make sure that buttons ID is the same when rendered to the page as it is in Visual Studio. – Gregg Duncan Oct 23 '15 at 20:59
  • you're right it did: MainContent_btnRegister" thanks! – wtwe Oct 23 '15 at 21:01

0 Answers0