Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove disabled attribute using JQuery [duplicate]

I have tried following code given in JSFIDDLE...

But it is not working...

I want to Enable submit button only after filling all input fields....

JSFIDDLE

code tried :

<script>
 (function() {
   $('form > input').keyup(function() {

    var empty = false;
    $('form > input').each(function() {
        if ($(this).val() == '') {
            empty = true;
        }
    });

    if (empty) {
        $('#register').attr('disabled', 'disabled'); 
    } else {
        $('#register').removeAttr('disabled'); 
    }
 });
})()
</script>
like image 546
Dr Manish Lataa-Manohar Joshi Avatar asked Jun 24 '26 22:06

Dr Manish Lataa-Manohar Joshi


1 Answers

What you're looking for is:

$('#register').prop('disabled', true); //makes it disabled
$('#register').prop('disabled', false); //makes it enabled
like image 110
Rhys Bradbury Avatar answered Jun 26 '26 11:06

Rhys Bradbury