I have something here that cannot seem to help me disable the submit button. any ideas?
<
Before jQuery 1.6 attr
was OK, after 1.6 you must use prop
.
$('#checky').click(function(){
$('#postme').prop('checked', !$(this).checked);
})
Attributes and properties are different things, but unfortunately jQuery took a long time to differentiate between them.
See also: .prop() vs .attr()
change $(this).checked
to if($(this).attr('checked') == false){
Here you go.
Add to the button #postme
a click event that checks if the check box is checked. If it is checked, return false, otherwise return true.
$('#postme').click( function () {
if ( !$('#checky').attr('checked') ) {
return false;
}
});
Try this
$(document).ready(function(){
$("#postme").attr("disabled","disabled");
$("#checky").click(function(){
if($("#checky").is(":checked")){
$("#postme").removeAttr("disabled");
}
else{
$("#postme").attr("disabled","disabled");
}
});
})
Try this way
$('#checky').click(function(){
if(this.checked == false){
$('#postme').attr("disabled","disabled");
}
else {
$('#postme').removeAttr('disabled');
}
});
if(!$(this).is(':checked') ...