Enable And Disable Button
I looked many examples here of enabling and disabling a button in javascript with jquery and any of them worked for me. Here my desperate situation.
Solution 1:
Disabled is a property, not an attribute.
Use:
$('#myButton').prop("disabled", "disabled");
Solution 2:
Javascript:
<scriptlanguage="javascript"type="text/javascript">functionSetButtonStatus(sender, target)
{
if ( sender.value.length >= 12 )
document.getElementById(target).disabled = false;
elsedocument.getElementById(target).disabled = true;
}
</script>
HTML:
<asp:TextBoxID="txtText"runat="server"onkeyup="SetButtonStatus(this, 'btnButton')"></asp:TextBox><asp:ButtonID="btnButton"runat="server"Text="Button"Enabled="false" />
Solution 3:
Use this.
$('#<%= myButton.ClientID%>').attr('disabled', 'disabled');
Solution 4:
Did you add jquery library in the head tag?
<scriptsrc="http://code.jquery.com/jquery-1.10.1.min.js"></script><scriptsrc="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
Solution 5:
Here is what I've done before.
//On document load
$(function(){
//Set button disabled
$("input[type=submit]").attr("disabled", "disabled");
//Append a change event listener to you inputs
$('input').change(function(){
//Validate your form here, example:var validated = true;
if($('#nome').val().length === 0) validated = false;
//If form is validated enable formif(validated) $("input[type=submit]").removeAttr("disabled");
});
//Trigger change function once to check if the form is validated on page load
$('input:first').trigger('change');
})
Post a Comment for "Enable And Disable Button"