表单重置后禁用保存/提交按钮

时间:2017-03-07 06:44:21

标签: javascript jquery

这是我根据选择facode启用/禁用保存按钮的代码,但我遇到的问题是,当用户选择facode后重置表单时,会启用保存按钮。我想禁用那个

  $('#save').attr('disabled', 'disabled');
    $('#myCoolForm').attr('disabled', 'disabled');
    $(document).on('change','#facode,#rb_facode',function(){
        if (buttonsDisable($(this).val())) {
            $('#myCoolForm').attr('disabled', false);
            $('#save').attr('disabled', false);
        } else {
            $('#myCoolForm').attr('disabled', 'disabled');
            $('#save').attr('disabled', 'disabled');
        }
    });
    function buttonsDisable(e) {
        if (e > 0) {
            return true;
        } else {
            return false
        }
    }

2 个答案:

答案 0 :(得分:1)

<xa-datasource jndi-name="java:jboss/datasources/ProcessEngine"
    pool-name="eap_app_mysql-DB" use-java-context="true" enabled="true">
    <xa-datasource-property name="ServerName">IP</xa-datasource-property>
    <xa-datasource-property name="Port">PORT</xa-datasource-property>
    <xa-datasource-property name="DatabaseName">processengine</xa-datasource-property>
        <driver>mysql</driver>
        <security>
            <user-name>username</user-name>
            <password>password</password>
        </security>
        <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
        <xa-pool>
            <min-pool-size>1</min-pool-size>
            <max-pool-size>60</max-pool-size>
            <prefill>false</prefill>
            <use-strict-min>false</use-strict-min>
            <flush-strategy>FailingConnectionOnly</flush-strategy>
            <no-tx-separate-pools>true</no-tx-separate-pools>
            <pad-xid>false</pad-xid>
            <wrap-xa-resource>true</wrap-xa-resource>
         </xa-pool>
         <validation>
            <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
            <validate-on-match>false</validate-on-match>
            <background-validation>false</background-validation>
            <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
         </validation>
</xa-datasource>

答案 1 :(得分:0)

请改用此方法:

$('#save').prop('disabled', true); // disabling the button

要启用按钮,请使用:

$('#save').prop('disabled', false); // enabling the button.

参考:http://api.jquery.com/prop/