开发者

Jquery disable button until ready

开发者 https://www.devze.com 2023-03-14 17:50 出处:网络
I am in the middle of this site here http://offline.raileisure.开发者_JAVA百科com/ the booking section on the right hand side, I need to be able to disable the book now button until the date,duration

I am in the middle of this site here http://offline.raileisure.开发者_JAVA百科com/

the booking section on the right hand side, I need to be able to disable the book now button until the date,duration and adult and children numbers are set..

I can't work out how to do it..

Any ideas ??

Thanks Lee


You can bind to the change handler on all your form elements... for example:

$(':input').change(function() {
    var complete;

    // check if your form is complete here

    // assumes the id of the button is 'bookNowButton'
    if (!complete) $('#bookNowButton').attr('disabled', true);
    else $('#bookNowButton').removeAttr('disabled');
});

To simplify the enable/disable functionality I'd also perhaps suggest changing your "Book Now" button to an <input type="image" /> instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消