Tuesday, April 16, 2013

Disable "Save" Button Until User Selects "I Agree"

Requirement is: Don't allow the end user to submit a record until they Agree with the terms and conditions by selecting "I Agree".

So, we've to disable "Save" button until the "I Agree" check box is checked! Here is the jQuery script to achieve the same. Just place this code in your custom list form or in Content Editor Web Part (Place it in a Text file, upload and specify the script in CEWP).

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>

<script language="javascript">

$(document).ready(function(){
 //Disable the "Save" button initially
  $("input[value$='Save']").attr('disabled', true);  

 //alert('jQuery Works');


 //Enable-Disable "Save" button based on "I Agree" checkbox value!
   $("input[title$='Agree to Delete this site']").click(function(){
        if(this.checked)
           {
            $("input[value$='Save']").attr('disabled', false);
           }      
        else
           {
            $("input[value$='Save']").attr('disabled', true);  
           }
     }); 

  });

</script>
Code in action: If  "I Agree" check box isn't enabled:

After selecting  "I Agree" check box: Save button enabled!



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

6 comments :

  1. Hi Salaudeen,

    How to create custom List form ?

    ReplyDelete
    Replies
    1. Use SharePoint Designer to create a custom list form and place the code below "PlaceHolderMain". You can edit the page in Browser, add a CEWP and use the above code as well.

      Delete
  2. Hi,
    In the same way.
    how to check if the field is empty or not?. Please let me know
    I apprciateyour help.
    Thanks
    Stacy

    ReplyDelete
    Replies
    1. Here you Go:

      if($('input[title$='RequiredTextFileld]').val() == ""))
      {
      alert("Please Provide value for Required Text Field!");
      }

      Delete
  3. Thanks,
    But its not working. I hope u can me with this. I have field called Minutes which is a TextBox. When the user enter the numbers I want to check the value should not be less than 15. How do i do that using Jquery.
    I Appreciate your help
    Thanks,
    Stacy

    ReplyDelete
  4. Hi Sir,
    I have used this code for disabling 'Save' button, but my other outcome button 'Reviewed' stopped to work. Sir, please can you help me with this, I want to disable 'Save button' but I want 'Reviewed' button to work...

    Thank you in Advance

    Inom

    ReplyDelete

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...