I am trying to get some jQuery to disable the confirm button on my form if the dropdown list is a certain value, but it doesnt seem to be working.
I have read lots of posts on here and tried various different ways.
Here is my code at the moment:
<script>
$(document).ready(function () {
// Handler for .ready() called.
$('#MoveToCompanyId').attr("disabled", true);
$('#DeleteAll').live("click", function () {
if ($(this).attr("value") == "True") {
$('#MoveToCompanyId').attr("disabled", true);
} else {
$('#MoveToCompanyId').attr("disabled", false);
$('#confirm').attr("disabled", true);
$('#MoveToCompanyId').change(function () {
if ($("#MoveToCompanyId option:selected").text() != "---Select Company---") {
$('#confirm').removeAttr("disabled");
alert($("#MoveToCompanyId option:selected").text());
}
else {
$('#confirm').attr("disabled", true);
alert("I should be disabled!");
}
});
}
});
});
</script>
Can anyone see any problems with it?
Just to clarify, i know it gets into the correct code blocks as my alerts are working. Its just the button disabling that is not working.
Kind Regards,
Gareth
You should be using
if you are using jQuery 1.6+ then you should be using prop.
Read more about prop