JQuery: input type = submit is still submitted even if disabled
I have a submit button that I'm trying to disable programmatically, but for some reason, when I change the disabled attribute of an element, I can still click the submit button and the event code still fires.
As an example, I have the following element in my html:
<input name="reg_submit" id="reg_button" value="Buddy" class="reg_button reg_button_new crm_submit" type="submit">
and in my script include the following:
var k = jQuery.noConflict();
k('#reg_button').attr("disabled", true);
And when I type debug the item is actually disabled. Is my approach wrong?
+3
source to share
1 answer
You can try setting a disabled property.
var k = jQuery.noConflict();
k('#reg_button').prop("disabled", true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input name="reg_submit" id="reg_button" value="Buddy" class="reg_button reg_button_new crm_submit" type="submit">
+1
source to share