Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript prop('required', true) works but prop('required', false) doesn't?

Why does the $('#select_embed') property get set to true, but not to false? Instead, I tried removeAttribute('required'), but that didn't work either.

<script>

    function showBundles(){
        if (document.getElementById("embed").checked){
            $('#div_embed_bundles').show('fast')
            $('#select_embed').prop('required',true);
        }
        else {
            $('#div_embed_bundles').hide('fast')
            $('#select_embed').prop('required',false);
        }
    }

</script>
like image 966
MFB Avatar asked Sep 01 '11 00:09

MFB


1 Answers

Ideally if prop('required',true) is working then prop('required',false) should also work. But you can try with removeAttr, hope this helps.

function showBundles(){
        if (document.getElementById("embed").checked){
            $('#div_embed_bundles').show('fast')
            $('#select_embed').prop('required',true);
        }
        else {
            $('#div_embed_bundles').hide('fast')
            $('#select_embed').removeAttr('required');
        }
    }
like image 86
ShankarSangoli Avatar answered Oct 18 '22 00:10

ShankarSangoli