FarwallGhost
FarwallGhost

Reputation: 718

Disable submit button in JavaScript until user share the facebook page.

My Question is:

How to Disable submit button in JavaScript until user share the facebook page.

I am using radio buttion for show/hide facebook share button.

---------JavaScript for show/hide the div----------------

<script type="text/javascript">
    $(document).ready(function(){
        $('input[type="radio"]').click(function(){
            if($(this).attr("value")=="low"){
                $(".box").hide();
                $(".low").show();
            }
            if($(this).attr("value")=="high"){
                $(".box").hide();
                $(".high").show();
            }

        });
    });
</script>

---------css----------------

.box{
        padding: 5px;
        display: none;
        margin-top: 20px;
        border: 1px solid #000;
        width:80%;
    }

------------html---------------

<label><input type="radio" name="priority" value="low" id="priority_0" />Low</label>
<label><input type="radio" name="priority" value="high" id="priority_0" />High</label>
<input type="submit" name="button" id="adbtn" value="" />

<div class="low"></div>
<div class="high box">Here is facebook page link to be share </div>

I want when the user click on the high radio button then submit button should be disabled. then user share the page on facebook after sharing the page the submit button get enabled.

Thanks in advance.

Upvotes: 0

Views: 174

Answers (1)

RGS
RGS

Reputation: 5211

<script type="text/javascript">
    $(document).ready(function(){
        $('input[type="radio"]').on('change', function(){
            if($(this).val()=="low"){
                $(".box").hide();
                $(".low").show();
                $('input[type="submit"]').removeAttr('disabled');
            }
           else if($(this).val()=="high"){
                $(".box").hide();
                $(".high").show();
                $('input[type="submit"]').attr('disabled','disabled');
            }

        });
    });
</script>

Use 'change' instead of 'click' event.

Upvotes: 0

Related Questions