I have a problem in a form where I do some jquery validations. If a specific input field is not filled out, it should disable a \"step forward\" button by adding a disabled attr
I think, disabling click
event is not a good idea. Because you have to enable click
event again, if you enable the button.
For disabled button
, I just check disabled state
, if disabled
return
.
Book
$('.btn-move-forward').addClass('disabled');
$('.btn-move-forward').on('click', function(){
if($(this).hasClass('disabled')) {
console.log('-- Button is disabled. Return from here. --');
return false;
}
// write code for click event here
$('#step2, #step3').toggle()
});